Music button press 1 time, turn music off, press 2nd time, turn music on

Braydon_SFXBraydon_SFX Member, Sous Chef, Bowlboy Sidekick Posts: 9,273
edited November -1 in Working with GS (Mac)
Hey there,

Like the title says, I want my music button to, when you press it the first time, turn the music off.
And when you press it the second time, it turns the music back on.

Thanks a lot!

Comments

  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    Search the cookbook videos for on off switch. It does just exactly that.
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    Have your attribute called musicOff and have it set to 0

    In your button have a rule when touch is pressed:
    -change attribute musicOff to (musicOff+1)%2

    that will toggle it between 0 and 1

    then have your rule when attribute musicOff=0
    -change attribute device.audio.music to 1
    otherwise change to 0
  • Rob2Rob2 Member Posts: 2,402
    'change musicoff to 1-musicoff' is an even simpler way of toggling between 0 and 1 ;)
  • Braydon_SFXBraydon_SFX Member, Sous Chef, Bowlboy Sidekick Posts: 9,273
    JohnPapiomitis said:
    Have your attribute called musicOff and have it set to 0

    In your button have a rule when touch is pressed:
    -change attribute musicOff to (musicOff+1)%2

    that will toggle it between 0 and 1

    Thanks M8, that worked. :-)

    then have your rule when attribute musicOff=0
    -change attribute device.audio.music to 1
    otherwise change to 0

Sign In or Register to comment.