Setting Attributes & Values to NPCs Help

CheshireTiger
16 Oct 2019, 19:45I have a few social routes planned and i think setting attributes and values can track progress the character is making on each one. But in not sure how to make it work properly
for example: after talking with NPC , an attribute called Ego is started on him and set to value 1
later the Ego value 1 is used in an IF script

Io
16 Oct 2019, 19:51Say you have an object called MrPersonGuy, with attribute Ego. You give him that attribute when making the game, rather than adding it mid-game.
It starts as, I don't know, 0. And then at the right moment:
MrPersonGuy.Ego=1
And when you need it:
if (MrPersonGuy.Ego=1){
//Stuff if it's 1
}
else{
//Stuff if it's not 1
}
Hope this answers your question!

CheshireTiger
16 Oct 2019, 22:29it really didnt though....
i know how to set it with if, its just that the atribute dosest seem to work
ShadowsEdge19
16 Oct 2019, 22:58Can you share some of the code that doesn't work?

CheshireTiger
17 Oct 2019, 01:15dont know how to share code. but i can link to image...
https://imgur.com/go5Aq1U
ShadowsEdge19
17 Oct 2019, 05:40Where's your attempt at using an IF condition?
To share code there is a Code View button at the top of the section where you added the message, just copy that and paste the full thing in here and follow the guide on the right of the post text box to put it in a specific code display box.
hegemonkhan
17 Oct 2019, 07:44(filler for getting my edited post, updated/posted)
IMPORTANT:
replace my upper case stuff below (NAME_OF_OBJECT and NAME_OF_ATTRIBUTE), with what you're using in your game, of course
(quest is case-sensitive, for example: player.strength, is NOT the same as, player.Strength)
IMPORTANT:
there's a big difference between an 'int (integer)' (an amount) Data/Attribute/Value Type and a 'string' (a NON-amount) Data/Attribute/Value Type
for example: 1, is NOT the same as, "1"
Integer Value: 1
String Value: "1"
Arithmetic (Amounts: integers and doubles):
1 + 1 = 2
5 + 5 = 10
55 + 55 = 110
2 * 2 = 4
VS
Concatenation (NON-amounts: strings, for this example):
"1" + "1" = "11"
"5" + "5" = "55"
"55" + "55" = "5555"
"2" * "2" = ERROR!
// normally, this would produce an error, but I think quest will automatically convert the integer into a string, for example:
"1" + 1 = "11"
"1" + (integer: 1 -> converted into -> string: "1") = "11"
"1" + ("1") = "11"
so, if you got this:
if (NAME_OF_OBJECT.NAME_OF_STRING_ATTRIBUTE = 1) { SCRIPTING }
it'll cause an ERROR: checking if a String compares with an Integer
or this:
if (NAME_OF_OBJECT.NAME_OF_INTEGER_ATTRIBUTE = "1") { SCRIPTING }
it'll cause an ERROR: checking if an Integer compares with a String
if you used the GUI/Editor:
'NAME_OF_OBJECT' Object -> 'Attributes' Tab -> Attributes (box at the bottom) -> Add
then, make sure it's set as an 'int (integer)' Attribute Type:
(Object Name: NAME_OF_OBJECT)
Attribute Name: NAME_OF_ATTRIBUTE
Attribute Type: int
Attribute Value: 0 // or whatever value you want it to start as
if you're using the scripting, it'll automatically set/parse the Attribute Type based upon the Value that you give/set it as:
add new script -> 'variables' section/category -> 'set a variable or attribute' Script -> (see below, using '0' as the starting value, for this example)
set variable NAME_OF_OBJECT.NAME_OF_ATTRIBUTE = [EXPRESSION] 0
you can also, after you created/added/set the Attribute, increase/decrease it's Value, however you want (instead of just re-setting it to another Value):
add new script -> 'variables' section/category -> 'set a variable or attribute' Script -> (see below)
Addition (simple example):
set variable NAME_OF_OBJECT.NAME_OF_ATTRIBUTE = [EXPRESSION] set variable NAME_OF_OBJECT.NAME_OF_ATTRIBUTE + 9
Subtraction (simple example):
set variable NAME_OF_OBJECT.NAME_OF_ATTRIBUTE = [EXPRESSION] set variable NAME_OF_OBJECT.NAME_OF_ATTRIBUTE - 6
Multiplication (simple example):
set variable NAME_OF_OBJECT.NAME_OF_ATTRIBUTE = [EXPRESSION] set variable NAME_OF_OBJECT.NAME_OF_ATTRIBUTE * 3
Division (simple example):
set variable NAME_OF_OBJECT.NAME_OF_ATTRIBUTE = [EXPRESSION] set variable NAME_OF_OBJECT.NAME_OF_ATTRIBUTE / 2
then, in your 'if' Script, make sure you put in the Attribute (NAME_OF_OBJECT.NAME_OF_ATTRIBUTE):
if using the GUI/Editor:
add new script -> 'scripts' section/category -> 'if' Script -> (see below)
if [EXPRESSION] NAME_OF_OBJECT.NAME_OF_ATTRIBUTE = 0
-> then -> add new script
// optional (as many-more or less 'else ifs' as needed):
else if [EXPRESSION] NAME_OF_OBJECT.NAME_OF_ATTRIBUTE = 1
-> then -> add new script
else if [EXPRESSION] NAME_OF_OBJECT.NAME_OF_ATTRIBUTE = 2
-> then -> add new script
// optional:
else
-> add new script
if (NAME_OF_OBJECT.NAME_OF_ATTRIBUTE = 0) {
// scripting
}
// optional example:
else if (NAME_OF_OBJECT.NAME_OF_ATTRIBUTE = 1) {
// scripting
}
// optional example:
else if (NAME_OF_OBJECT.NAME_OF_ATTRIBUTE = 2) {
// scripting
}
// optional example: more or less 'else ifs'
// optional example:
else {
// scripting
}
you can also use other comparative operators/operations too, for example, 'greater than' (top to bottom):
if (NAME_OF_OBJECT.NAME_OF_ATTRIBUTE > 66) {
// scripting
}
// optional example:
else if (NAME_OF_OBJECT.NAME_OF_ATTRIBUTE > 33) {
// scripting
}
// optional example:
else {
// scripting
}

CheshireTiger
17 Oct 2019, 12:40I already have the IF script written up, its the attribute im concerned with. I do not intend to use interger if i can help it.
"Thanks for all the held, buddy. I really owe you for this."
"You do indeed..." he says in a wierd tone that you overlook
")
set (Sheldon, Ego, 1)
ShadowsEdge19
17 Oct 2019, 13:10If you aren't going to use integers then what we're you thinking of instead?

CheshireTiger
17 Oct 2019, 13:20i was thinking thinking i could set it to 1 once the route starts and set it to 2 at the next part of the route and so on

CheshireTiger
17 Oct 2019, 13:47this is what i have written as start of route https://imgur.com/94W6CGC
but it results in this https://imgur.com/g07ou6Y

Io
17 Oct 2019, 15:01Are you sure that Sheldon has an Ego attribute at all? Because the error is saying that it doesn't.
ShadowsEdge19
17 Oct 2019, 16:22If you do in fact have an "Ego" attribute on your object, or parent object that Sheldon inherited from, then you most likely need to set the value to 0 inside the attribute editor as trying to use Set on a variable that's never been given a value definition will result in that error.

CheshireTiger
17 Oct 2019, 18:36Yes its right there, isntvit?
There is no parent object in this case.
Ill try starting it off on 0

Io
17 Oct 2019, 18:45@ChesireTiger
Yes its right there isntvit?
No, it's not. What you've shown us is that your code tries to set Sheldon.Ego to 1. But that doesn't mean there IS a Sheldon.Ego. You could switch that code to make Sheldon.TEHEJNkrrtem8u96u54i equal 1, but that doesn't mean Sheldon has a TEHEJNkrrtem8u96u54i attribute.

CheshireTiger
17 Oct 2019, 19:03i tried adding this https://imgur.com/WigZxQz still not working
how do i set attribute no codeview?
mrangel
17 Oct 2019, 22:07@CheshireTiger
this is what i have written as start of route
That would correspond to the code: set (Sheldon, Ego, 1)
The code you want is set (Sheldon, "Ego", 1)
.
You've got it expecting Ego to be a string variable containing the name of the attribute you want to set; and it complains because there isn't a local variable called Ego
.
You could also use the line Sheldon.Ego = 1
, which is more efficient and doesn't require any quotes. I'm not sure what that would look like in the GUI editor, though.
@io
Are you sure that Sheldon has an Ego attribute at all? Because the error is saying that it doesn't.
No, the error is complaining about an undefined variable called Ego. The error for a missing attribute is different.
@ShadowsEdge19
trying to use Set on a variable that's never been given a value definition will result in that error.
No it won't. set
is perfectly capable of creating attributes.

CheshireTiger
17 Oct 2019, 23:42@mrangel itvseems tonhave worked, thanks