musik und sounds ausschalten?

  • #1, z nuncioFriday, 22. March 2013, 21:35 hodinky 12 years ago
    moin! in meinem menü möchte ich dem spieler ein paar tasten zeigen, die er im spiel drücken kann, darunter auch eine taste, um musik und / oder sound auszuschalten, aber ich weiß nicht genau, welcher befehl dafür der richtige ist.
    "gerade gespielten sound stoppen"? oder "lautstärke ändern" (auf 0)?

    Fanoušek fóra

    128 Posts


  • #2, z afrlmeFriday, 22. March 2013, 22:07 hodinky 12 years ago
    could you translate to English please?

    bing translation isn't making much sense.

    Imperátor

    7285 Posts

  • #3, z nuncioFriday, 22. March 2013, 22:38 hodinky 12 years ago
    how can i switch off sound and / or music to mute all game sounds? i want it to be a shortcut. i know how to create the shortcut but i don't know what's the right action i must chose from the list.

    Fanoušek fóra

    128 Posts

  • #4, z afrlmeFriday, 22. March 2013, 22:59 hodinky 12 years ago
    best method would be to use LUA to store current volume levels in a variable so that you can toggle between mute on/off.

    here's the script - it should be set as a "definition script" in the script options! - it should work but this is off the top of my head wink
    local musicVol = getObject('Values[val_musicVol]') -- get value for storing music volume
    local soundVol = getObject('Values[val_soundVol]') -- get value for storing sound volume
    local speechVol = getObject('Values[val_speechVol]') -- get value for storing speech volume
    local getCond = getObject('Conditions[cond_muteSound]') -- get condition for checking if sound is muted or playing
    
    -- let's create a function to toggle sound muted / playing!
    function toggleSound()
     local cond = getCond:getBool(VConditionValue) -- check condition value
     if not cond then
      getCond:setValue(VConditionValue, true) -- set condition to true
      musicVol:setValue(VValueInt, getVolume(eMusicVolume)) -- store current music volume
      soundVol:setValue(VValueInt, getVolume(eSoundVolume)) -- store current sound volume 
      speechVol:setValue(VValueInt, getVolume(eSpeechVolume)) -- store current speech volume
      setVolume(eMusicVolume, 0) -- set music volume to "0"
      setVolume(eSoundVolume, 0) -- set sound volume to "0"
      setVolume(eSpeechVolume, 0) -- set speech volume to "0"
     else
      getCond:setValue(VConditionValue, false) -- set condition to false!
      setVolume(eMusicVolume, musicVol) -- restore music volume
      setVolume(eSoundVolume, soundVol) -- restore sound volume
      setVolume(eSpeechVolume, speechVol) -- restore speech volume
     end
    end
    

    call it by executing a script & typing in the function name.
    toggleSound()

    Imperátor

    7285 Posts

  • #5, z nuncioSaturday, 30. March 2013, 14:34 hodinky 12 years ago
    cool, danke. i'll try this later when i have my first demo game finished!

    Fanoušek fóra

    128 Posts

  • #6, z afrlmeSaturday, 30. March 2013, 15:10 hodinky 12 years ago
    hmm I was thinking it would be better to add the current values inside of values inside of the editor - that way they will be correctly set based on any save you decide to load rather than relying on the variables.

    I have updated the script (above) to reflect what I have said, above.

    Imperátor

    7285 Posts

  • #7, z nuncioThursday, 04. April 2013, 00:21 hodinky 12 years ago
    i created a new script created it as "definition script" and pasted your script into it. when i hit F4 i execute a script and typed "toggleSound()" but it doesn't work roll

    Fanoušek fóra

    128 Posts

  • #8, z afrlmeThursday, 04. April 2013, 00:57 hodinky 12 years ago
    what does it say in the log?

    the script was off the top of my head so I wasn't sure if it was correct or not ...

    did you add the conditions/values listed in the script somewhere inside of the editor?

    Imperátor

    7285 Posts

  • #9, z nuncioSaturday, 06. April 2013, 00:58 hodinky 12 years ago
    i just copied the text and pasted it into the script
    did you add the conditions/values listed in the script somewhere inside of the editor?
    i think i didn't. i have no idea how scripting works, not at all smile

    Fanoušek fóra

    128 Posts

  • #10, z afrlmeSaturday, 06. April 2013, 01:28 hodinky 12 years ago
    you need to create the values: "val_musicVol", "val_soundVol", "val_SpeechVol" & the condition: "cond_muteSound" somewhere inside of the Visionaire Studio editor.

    if it doesn't work after that, then let me know what is says in the messages.txt & visedit.txt log files.

    P.S: "m" key would be more ideal for as "m" for "mute" & it should be set as "m (released)" or whatever it is in German; so that it only performs the execute script: "toggleSound()" when the key has been released to prevent it looping between on or off.

    Imperátor

    7285 Posts