GameSalad

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Toggle Button performing both acts per click, what do?

MoikMoik Posts: 257Member, PRO
edited January 2016 in Working with GS (PC)

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

  • SocksSocks London, UK.Posts: 12,822Member

    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.

  • MoikMoik Posts: 257Member, PRO

    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.

  • SocksSocks London, UK.Posts: 12,822Member
    edited January 2016

    @Moik said:
    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 !

  • MoikMoik Posts: 257Member, PRO

    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!

  • The_Gamesalad_GuruThe_Gamesalad_Guru Posts: 9,913Member

    That code above will just loop as long as the mouse button is down.

Sign In or Register to comment.