Boolean True On Click?

Peter_JPeter_J Member Posts: 17
edited March 2013 in Working with GS (Mac)
Hello all,

How do I make a boolean attribute "true" when you click an object?

Thanks in advance!

Regards,

Peter

Comments

  • Braydon_SFXBraydon_SFX Member, Sous Chef, Bowlboy Sidekick Posts: 9,273
    Create a rule inside the actor you want to press -

    Rule:

    When touch is pressed,
    Change attribute game.boolean to true.
  • AdamgoproAdamgopro Member Posts: 310
    Make rule inside the actor " when touched is pressed"

    Add behaviour : Change attribute True/False
  • Peter_JPeter_J Member Posts: 17
    @Bradyon_SFX , @Adamgopro Excellent! Thanks to both of you!

    Regards,

    -Peter
  • Brand0n1210Brand0n1210 Member Posts: 12
    For a future reference if you want it to turn back to false if pressed again (not sure what your using it for) You create a rule when touch is pressed then throw another another rule in there that says if bool is true change it to false then go to otherwise and put in change attribute to true. This way every time you click the actor it will switch between true and false.
  • CodeMonkeyCodeMonkey Head Chef, Member, PRO Posts: 1,803
    For a future reference if you want it to turn back to false if pressed again (not sure what your using it for) You create a rule when touch is pressed then throw another another rule in there that says if bool is true change it to false then go to otherwise and put in change attribute to true. This way every time you click the actor it will switch between true and false.
    (Grumpy Monkey) No.

    This will result in possible endless loops. I would go with a numerical attribute. So when touch is pressed Change Attribute game.NumericalTF = 1-game.NumericalTF

    Then is just switches between 0 and 1 and there are no endless loops.
  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    Expanding on the numerical route you can also do

    When touch is pressed
    --change attribute to (game.attribute+1)%2


    That will also switch back and forth between 0 and 1 for each press of the actor.

    Just goes to show you there's more that one way to skin a cat...

    Lol
Sign In or Register to comment.