Simple Mute Button?

  • #1, by ygmantellFriday, 14. July 2017, 16:14 8 years ago
    I want to have a simple button (or tiggered by the M key) that will shut off all sounds, and then turn them back on when clicked/pressed again. 

    I know there is a guide on how to do this in the Wiki, but I really know nothing about scripting (but intend on learning more).

    Can someone either walk me through the steps, or recommend a simpler way to do this?


    Thanks so much!

    Great Poster

    274 Posts


  • #2, by afrlmeFriday, 14. July 2017, 16:38 8 years ago
    There was 2 additional volume channels added into Visionaire Studio 4.x. eGlobalVolume & eMovieVolume. The global volume channel is essentially the master volume channel that all the different volume channels are linked to, so you could easily toggle it like so...

    1. create a key action for "m (released)" - note the released bit, it's important.
    2. inside of that action create an execute a script action part & add this block of code to it...
    if getVolume(eGlobalVolume) > 0 then
     setVolume(eGlobalVolume, 0)
    else
     setVolume(eGlobalVolume, 100)
    end

    & that should do it. smile

    Imperator

    7285 Posts

  • #3, by ygmantellFriday, 14. July 2017, 19:07 8 years ago
    This worked perfectly, thank you!

    One question:
    I set up Space and Esc to show a pause menu, and S to execute an autosave.  
    Should I change them to be on key released?  If so, why?
    What is the difference if it is just for a single button press?

    Thanks!

    Great Poster

    274 Posts

  • #4, by afrlmeFriday, 14. July 2017, 19:22 8 years ago
    Key (released) only triggers the actions once the player lets go of the key, whereas the regular key actions work like the turbo button on a gamepad; in other words if you use a regular key action, then it ends up looping through the actions indefinitely while the player is keeping the key pushed down which isn't a good thing if the actions are saving something or are toggling between one thing & another.

    Example. Let's say you are using ESC to toggle between the main menu & also to switch back to the previous scene, now because you are toggling between the two scenes it will keep switching between them until the player lets go.

    Regular key press would be more desired for say sliding something out or moving a character. Anyway... I always recommend using Key (released) key events unless a situation requires the regular key event type.

    Imperator

    7285 Posts

  • #5, by ygmantellFriday, 14. July 2017, 19:35 8 years ago
    Perfect, thank you!

    Great Poster

    274 Posts