Actors affecting other actors through game attributes
Sprucie
Member Posts: 12
I'm having some trouble making one actor trigger the behavior of another. Specifically, I want one actor (a button) to change the visibility of another actor (like a light being turned on). I also want the light's on-ness to cause other things to happen -- like running an animation of the light coming on -- so I don't want to constrain the light's self.graphics.visible exclusively. From poking around on these forums, it sounds like the best way to do that is like so:
---
Game attribute:
game.light_on(boolean)
Button Actor:
Rule: if touch is pressed, set game.light_on to true
Light Actor:
attribute: self.on
Constrain self.on to game.light_on
Rule: if self.on is true
set self.graphics.visible to true
animate
//some other stuff
---
However, despite this seemingly simple situation, pressing the button does *not* do any of the actions I want: no visibility, no animation, no other stuff. Nothing happens (although through testing I have determined that game.light_on is indeed being set correctly).
If I could, I'd like to constrain the animation and visibility and stuff to game.light_on as well -- so it updates continuously -- but my understanding is that I can't constrain attributes of different data types. (In other words, I can't somehow say "watch this game attribute and fire off an animation as soon as the attribute becomes value X.")
What am I missing? Do I have some fundamental misunderstanding? I come from a programming background and sometimes I have difficulty translating my usual way of doing things to the GS model.
Thanks!
---
Game attribute:
game.light_on(boolean)
Button Actor:
Rule: if touch is pressed, set game.light_on to true
Light Actor:
attribute: self.on
Constrain self.on to game.light_on
Rule: if self.on is true
set self.graphics.visible to true
animate
//some other stuff
---
However, despite this seemingly simple situation, pressing the button does *not* do any of the actions I want: no visibility, no animation, no other stuff. Nothing happens (although through testing I have determined that game.light_on is indeed being set correctly).
If I could, I'd like to constrain the animation and visibility and stuff to game.light_on as well -- so it updates continuously -- but my understanding is that I can't constrain attributes of different data types. (In other words, I can't somehow say "watch this game attribute and fire off an animation as soon as the attribute becomes value X.")
What am I missing? Do I have some fundamental misunderstanding? I come from a programming background and sometimes I have difficulty translating my usual way of doing things to the GS model.
Thanks!
Comments
---
Game attribute:
game.light_on(boolean)
Button Actor:
Rule: if touch is pressed, set game.light_on to true
Light Actor:
Rule: if game.light_on is true
set self.graphics.visible to true
animate
//some other stuff
---
Unfortunately, I tried this and it also didn't work -- with the same results: nothing happened. Despite my rule "if game.light_on is true then do a bunch of things...", none of those things happened.
Also, is there some way to find out if there are other attributes that can't be changed in game? Those would probably be good for me to know about so I don't beat my head against a wall for two hours.
Thanks!