toggle states on interact [SOLVED]

Started by rickious, Wed 15/04/2015 20:57:02

Previous topic - Next topic

rickious

So, for example, a light switch.  You click interact and a light turns on (object.Visible = true)  But I want to then click the same switch again for (object.Visible = false). 

I can do this with a workaround, like on clicking the switch (hotspot on room background image) an object appears over the switch and that becomes the next clickable area to make the light invisible and also hide the switch object, revealing the hotspot instead.

But im thinking there is probably a much simpler way.  Let me know as im sure you do  (nod)
--COMING SOON--
'Body Pharm' beta demo.

Body Pharm - coming soon!

ChamberOfFear

This is very simple indeed.
Code: ags
gLight.Visible = !gLight.Visible;


Setting a boolean variable to itself with a '!' in front will give the effect of flipping a switch. Since !booleanVariable means the opposite of whatever value that boolean currently holds.

rickious

Awesome! knew there would be an easy way but 1 character, that's excellent!  Cheers  (nod)
--COMING SOON--
'Body Pharm' beta demo.

Body Pharm - coming soon!

SMF spam blocked by CleanTalk