Conditions/Values resetting between scenes - Sound On/Off problem in Menu

  • #1, by tom-barnetFriday, 26. November 2021, 09:27 2 years ago
    Hello,

    in my game, I have a main menu where you can select New/Continue game, view Credits etc. and turn Music and Sound On/Off. 

    Since I don't know Lua, I set up a system of conditions (originally I tried values), and depending on them either a Sound On or Sound Off icon is shown on a button that controls Sounds (and the same for Music).

    All works well when I stay within the Menu Scene, however, once I turn off the sound/music (the icon changes) and then go to the first level and return back to the Menu again, the icons are always reset to the original state of the condition (or value), which in this case indicates that sound is on (although it is off).

    I suspect the conditions/values reset to their original state when you switch between the scenes. Is there a way to create global universal conditions that will not reset when changing the scene? Or is there any other solution to this problem that I'm missing?

    Alternatively, I thought this could be nicely solved by using Lua and animation of two frames (sound on/off) like people use in inventory for selected items. What frame would be shown would be dependent on the value of sound/music volume being either 0 or 100 (i really just want it on/off, no volume slider). So it would be something like (following does not attempt the be a real script)

    if game sound volume is 0, then activanimation "soundicon" first frame = 1
    else if sound volume is 100, then activanimation "soundicon" first frame = 2

    However, I don't know Lua so have no idea how to script this. Could somebody help me please and if the first solution is impossible, let me know what script to use? 

    Newbie

    37 Posts