[SOLVED] Unable to set an attribute within dialog

dcatley

  • Posts: 19
I'm trying to set a boolean attribute to true if the player activates a specific piece of dialog in my game. I've tried to understand this description from the API page but I just don't understand the example:

Messaging Scripts
<setattr [ATTR VALUE:ANY]>
Sets an attribute.
Ex: <setattr [actor Player "Health Behavior" _health 100]>

Here's what I typed up in my game, but it's not working - I mean, the game works, no errors appear, but the Boolean is not becoming true. When my scene is created, the Boolean attribute "Choice1Bad" is set with a value of false.

Oh...well that sucks... <but> <setattr [Boolean "Choice1Bad" _Boolean True]>

Any help with what I'm doing wrong would be greatly appreciated!

Daniel

« Last Edit: December 22, 2014, 01:04:20 pm by Justin »

dcatley

  • Posts: 19
Woohoo! I think I solved it myself after some sleuthing through this forum. Looks like I had to change the attribute to be a universal game attribute, rather than an attribute within a certain scene, and I changed the code to this:

<setattr [game "Choice1Bad" true]>

That API example is super confusing.

Justin

  • *
  • Posts: 4666
Good to see you got it working. Here's where you went wrong originally.

<setattr [Boolean "Choice1Bad" _Boolean True]>

I'm assuming that "Choice1Bad" is the name of your scene behavior, and you have an attribute in that behavior named "Boolean". In that case, all you needed to do was change "Boolean" to "scenebhv".

1) The first argument in the list is always what type of resource the attribute is found in. Either game, scenebhv, actorbhv, actor, or dialog.

2) If you chose actor or actorbhv, you need to specify an actor name.  The name is based on your use of the following snippet: GlobalActorID.set("Actor Name", _ActorAttribute);

3) If you chose scenebhv or actorbhv, you need to specify a behavior name.

4) And for all types, last is the attribute name and desired value.
For Live Support: Join our discord server and ping me @justin.
I'm most often available between 10am and 10pm Japan time. (GMT+9)

Ken Sowyer

  • Posts: 23
Looks like I had to change the attribute to be a universal game attribute, rather than an attribute within a certain scene, and I changed the code to this:

<setattr [game "Choice1Bad" true]>


I was in the same situation, that helps me, thanks!