Advertisement
AFRLme

get|setVolume & Play FX|Vox from an sceneAction [VS] (works)

Nov 6th, 2012
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.45 KB | None | 0 0
  1. -- int {0 = music, 1 = sound, 2 = voice}
  2. -- execute from an object with execute script: PlusMinus_Vol(int, false|true) [checks if volume less|more than 0%|100% else volume = volume -|+ 10%]
  3. -- play_sound | play_speech variables will do whatever is assigned to the actions when you call them with startAction(play_sound|speech)
  4.  
  5. -- examples ...
  6. -- music minus: PlusMinus_Vol(0, false) | music plus: PlusMinus_Vol(0, true)
  7. -- sound minus: PlusMinus_Vol(1, false) | sound plus: PlusMinus_Vol(1, true)
  8. -- voice minus: PlusMinus_Vol(2, false) | voice plus: PlusMinus_Vol(2, true)
  9. -- local play_sound = getObject("Scenes[insert_scene_name_here].SceneActions[insert_action_name_here]")
  10.  
  11. function PlusMinus_Vol(val, cond)
  12.  
  13. -- globals
  14. local check_vol = getVolume(val) -- gets current volume level for int specified!
  15. local play_sound = getObject('Scenes[Options_Menu].SceneActions[play_sound]') -- edit scene name & action name to suit
  16. local play_speech = getObject('Scenes[Options_Menu].SceneActions[play_speech]') -- edit scene name & action name to suit
  17.  
  18.  if cond == true then
  19.    check_vol = check_vol + 10
  20.    if check_vol > 100 then check_vol = 100 end
  21.  else
  22.    check_vol = check_vol - 10
  23.    if check_vol < 0 then check_vol = 0 end      
  24.  end
  25.  
  26.   setVolume(val, check_vol)
  27.  
  28. -- plays a sound or speech file depending on current int defined!
  29.  if val == 1 then
  30.   startAction(play_sound)
  31.  else
  32.  if val == 2 then
  33.   startAction(play_speech)
  34.  else
  35.  end
  36.  end
  37.  
  38. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement