Setting Attributes & Values to NPCs Help

I 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

Say 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!


it really didnt though....
i know how to set it with if, its just that the atribute dosest seem to work


Can you share some of the code that doesn't work?


dont know how to share code. but i can link to image...
https://imgur.com/go5Aq1U


Where'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.


(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
}

I 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)


If you aren't going to use integers then what we're you thinking of instead?


i 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


this is what i have written as start of route https://imgur.com/94W6CGC

but it results in this https://imgur.com/g07ou6Y


Io

Are you sure that Sheldon has an Ego attribute at all? Because the error is saying that it doesn't.


If 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.


Yes its right there, isntvit?
There is no parent object in this case.
Ill try starting it off on 0


Io

@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.


i tried adding this https://imgur.com/WigZxQz still not working
how do i set attribute no codeview?


@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.


@mrangel itvseems tonhave worked, thanks


This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums