sound-helper.nas 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. var view_level_inside = props.globals.initNode("/sound/view-level-inside");
  2. var view_level_outside = props.globals.initNode("/sound/view-level-outside");
  3. var audio_level_doors = props.globals.initNode("/sound/outside-sound-lvl-doors");
  4. var audio_level_doors = props.globals.initNode("/sound/outside-sound-lvl-doors-L");
  5. var audio_level_doors = props.globals.initNode("/sound/outside-sound-lvl-doors-R");
  6. setlistener("sim/current-view/internal", func{
  7. if(getprop("sim/current-view/internal")==1){
  8. view_level_inside.setValue(1.0);
  9. view_level_outside.setValue(0.0);
  10. }else{
  11. view_level_inside.setValue(0.0);
  12. view_level_outside.setValue(1.0);
  13. }
  14. }, 1);
  15. var setDoorAudioLvl = func(){
  16. var lvl0 = getprop( "/sim/model/bo105/doors/door/position-norm");
  17. var lvl1 = getprop( "/sim/model/bo105/doors/door[1]/position-norm");
  18. var lvl2 = getprop( "/sim/model/bo105/doors/door[2]/position-norm");
  19. var lvl3 = getprop( "/sim/model/bo105/doors/door[3]/position-norm");
  20. lvl = lvl0+lvl1+lvl2+lvl3;
  21. if(lvl>1)
  22. lvl=1;
  23. lvl_l = lvl1+lvl3;
  24. if(lvl_l>1) lvl_l=1;
  25. lvl_r = lvl0+lvl2;
  26. if(lvl_r>1) lvl_r=1;
  27. setprop("/sound/outside-sound-lvl-doors",lvl);
  28. setprop("/sound/outside-sound-lvl-doors-L",lvl_l);
  29. setprop("/sound/outside-sound-lvl-doors-R",lvl_r);
  30. }
  31. setlistener("/sim/model/bo105/doors/door/position-norm", func{
  32. setDoorAudioLvl();
  33. }, 1);
  34. setlistener("/sim/model/bo105/doors/door[1]/position-norm", func{
  35. setDoorAudioLvl();
  36. }, 1);
  37. setlistener("/sim/model/bo105/doors/door[2]/position-norm", func{
  38. setDoorAudioLvl();
  39. }, 1);
  40. setlistener("/sim/model/bo105/doors/door[3]/position-norm", func{
  41. setDoorAudioLvl();
  42. }, 1);