musik und sounds ausschalten?

  • #1, by nuncioFriday, 22. March 2013, 21:35 8 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)?

    Forum Fan

    128 Posts


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

    bing translation isn't making much sense.

    Imperator

    6846 Posts

  • #3, by nuncioFriday, 22. March 2013, 22:38 8 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.

    Forum Fan

    128 Posts

  • #4, by afrlmeFriday, 22. March 2013, 22:59 8 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
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24

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

    Imperator

    6846 Posts

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

    Forum Fan

    128 Posts

  • #6, by afrlmeSaturday, 30. March 2013, 15:10 8 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.

    Imperator

    6846 Posts

  • #7, by nuncioThursday, 04. April 2013, 00:21 8 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

    Forum Fan

    128 Posts

  • #8, by afrlmeThursday, 04. April 2013, 00:57 8 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?

    Imperator

    6846 Posts

  • #9, by nuncioSaturday, 06. April 2013, 00:58 8 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

    Forum Fan

    128 Posts

  • #10, by afrlmeSaturday, 06. April 2013, 01:28 8 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.

    Imperator

    6846 Posts

Write post