Toggle Button performing both acts per click, what do?
So I have a button which turns a power-up on and off. Right now, when I click it, it starts in Off and ends in Off with a single click. What's happening is that one click fires both On and Off actions. I hooked up a counter to the On section, and the increment goes up with each click. It's firing the On as well when clicking it while Off. Both are working, but they go at the same time. Do I need to build in a cooldown timer? Is there a common logic trap I'm falling into? Every other button I've made only triggers once per click.
Specifics:
The first set of rules are set to fire when All of Mouse Over, Mouse Down, and a "Attribute" Condition are met. The Attribute is a text attribute. So if game.EnlargeState "is" Off (no quotes or anything, capitals all match, it fires properly), and you hit the button, it fires the actions to turn it on, which includes a Change Attribute to set game.EnlargeState to On.
The same actor also has an indentical set of Conditions but for when game.EnlargeState "is" On (caps match, fires correctly in the background). So, if the power-up is on, and you hit the button, it should fire the action to turn it off (Change Attribute sets game.EnlargeState to Off).
Comments
I find that block of text impenetrable too much information for my Jan1st brain . . .
I'm not sure if this helps in your particular scenario, but the simple maths of . . . .
Change X to 1-X
. . . is good for a GameSalad toggle, something that switches between two states, make sure X starts out as 1 or 0.
I just tried switching it over to that an encountered the same issue. This is how it originally looked. One click runs both these blocks.
I don't know what any of that means, or what the values are doing, are you simply trying to get an attribute to toggle on and off when an actor is touched ?
Edit: if these rules are in the same actor then they will both fire at the same time, which will get ugly !
It took some looking around but I solved it by using game.EnlargeState = 1 - game.EnlargeState. Basically the same thing as you suggested for my left/right-hand button toggle! Thanks!
That code above will just loop as long as the mouse button is down.
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS