game.Variable Not Changed But Once
cklester
Member Posts: 7
I have an actor with a rule that if game.BooleanA is true, change attribute game.RealA to game.RealA + 1.
I have a "Display Text" beneath that rule to display game.RealA, as well as game.Time (for debugging purposes to make sure Display Text is getting run, which it is).
When game.BooleanA gets changed to true (it starts off false), game.RealA gets 1 added, but only once! Should it not be adding one each and every iteration (frame/0.01 seconds/?)?!
I have a "Display Text" beneath that rule to display game.RealA, as well as game.Time (for debugging purposes to make sure Display Text is getting run, which it is).
When game.BooleanA gets changed to true (it starts off false), game.RealA gets 1 added, but only once! Should it not be adding one each and every iteration (frame/0.01 seconds/?)?!
Comments
I would suggest adding a timer in the rule. So if game.BooleanA is true, then timer for every 0.01 seconds, change attribute game.RealA to game.RealA +1.
It's like a repeat conditional being true but the statements not running...
while a do
b += 1
end while
Normally, in any other programming paradigm, 1 would get added to b continuously until a is false. But you are saying in GameSalad's case, while a is true, b only gets added to once. Given the construct, that's not logical.
It's possible I'm not completely understanding rules, but this seems clear cut.
Instead of change attribute, use constrain attribute. It will continuously update the value.
Quoting GameSalad: "Unlike the Change Attribute behavior, this behavior continuously updates the value of one attribute to that of another. For instance, an actors x and y position can continuously be constrained to that of the mouse."
So, change attribute only does the value change once while constrain does it continuously.
I've created an example project that demonstrates the issue. Even though the boolean value an actor is querying is 'true,' the conditional statements are not getting triggered. The game.Time display shows that the actor is being called frequently, which must mean the rule is getting ignored for some reason.
<s>How do I export a project into a single file? I want to post it online somewhere for GS experts to download and see.</s>
Project file in ZIP archive
Again, maybe this is how it's supposed to work (I hope not), but maybe not!