eno.nas 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  1. #### Eno ####
  2. ###
  3. # Settings
  4. var door = "canopy/position-norm";
  5. var max = 0.85; # Maximum volume when internal and door open
  6. var min = 0.2; # Volume when internal and door closed (what makes it through the door)
  7. var multiplier = 6; # How quickly volume reaches maximum as door opens
  8. var init = func {
  9. print("Initialising Eno");
  10. props.globals.initNode("sim/sound/eno/initialised",1,"BOOL");
  11. props.globals.initNode("sim/sound/eno/volume-out",1,"DOUBLE");
  12. var mpvol = props.globals.getNode("sim/sound/aimodels/volume").getValue();
  13. props.globals.getNode("sim/sound/eno/masters/aimodels",1).setValue(0.8);
  14. timer.start();
  15. }
  16. var loop = func() {
  17. var doorpos = props.globals.getNode(door).getValue();
  18. var view = props.globals.getNode("sim/current-view/internal").getBoolValue();
  19. var out = ( doorpos * multiplier );
  20. var mplevel = props.globals.getNode("sim/sound/eno/masters/aimodels",1).getValue();
  21. if ( out > max ) { out = max };
  22. if ( out < min ) { out = min };
  23. if ( !view ) { out = 1 };
  24. setprop("sim/sound/eno/volume-out", out);
  25. setprop("sim/sound/aimodels/volume", ( out * mplevel ));
  26. }
  27. var timer = maketimer(0.05, loop);