DMXlyre.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. var defaultTrigger = script.addTrigger("default","set DMX channels to default values");
  2. var pan_DMX = script.addFloatParameter("pan_DMX","pan position",.1,0,1); //This will add a float number parameter (slider), default value of 0.1, with a range between 0 and 1
  3. var tilt_DMX = script.addFloatParameter("tilt_DMX","tilt position",.1,0,1);
  4. var zoom_DMX = script.addFloatParameter("zoom_DMX","zoom position",.1,0,1);
  5. var focus_DMX = script.addFloatParameter("focus_DMX","pan position",.1,0,1);
  6. var dimmer_DMX = script.addFloatParameter("dimmer_DMX","light level",.1,0,1);
  7. function init()
  8. {
  9. //myFloatParam.set(5); //The .set() function set the parameter to this value.
  10. //myColorParam.set([1,.5,1,1]); //for a color parameter, you need to pass an array with 3 (RGB) or 4 (RGBA) values.
  11. //myP2DParam.set([1.5,-5]); // for a Point2D parameter, you need to pass 2 values (XY)
  12. //myP3DParam.set([1.5,2,-3]); // for a Point3D parameter, you need to pass 3 values (XYZ)
  13. }
  14. /*
  15. This function will be called each time a parameter of your script has changed
  16. */
  17. function defaultState(){
  18. local.send(7, 8); // STROBE
  19. local.send(12, 0); // PRISM
  20. local.send(8, 0); // COLOR
  21. local.send(11, 0); // STATIC GOBO
  22. local.send(9, 48); // ROTATING GOBO
  23. local.send(10,3); // GOBO ROTATION
  24. local.send(5, 200); //SPEED LIMIT
  25. local.send(15, 0); //built-in programs
  26. local.send(16, 0); //channel functions
  27. local.send(12, 0); //prism
  28. }
  29. function float2DMX(value){
  30. value = Math.floor(value * 65535);
  31. var MSB = value / 256;
  32. var LSB = value % 256;
  33. return [ MSB , LSB];
  34. }
  35. function scriptParameterChanged(param)
  36. {
  37. if(param.is(pan_DMX)){
  38. var values = float2DMX(param.get());
  39. local.send(1, values[0]);
  40. local.send(3, values[1]);
  41. }
  42. else if(param.is(tilt_DMX)){
  43. var values = float2DMX(param.get());
  44. local.send(2, values[0]);
  45. local.send(4, values[1]);
  46. }
  47. else if(param.is(zoom_DMX)){local.send(14, param.get()*255);}
  48. else if(param.is(focus_DMX)){local.send(13, param.get()*255);}
  49. else if(param.is(dimmer_DMX)){local.send(6, param.get()*255);}
  50. else if(param.is(defaultTrigger)){defaultState();}
  51. //You can use the script.log() function to show an information inside the logger panel. To be able to actuallt see it in the logger panel, you will have to turn on "Log" on this script.
  52. // script.log("Parameter changed : "+param.name); //All parameters have "name" property
  53. else if(param.is(myTrigger)) {script.log("Trigger !");} //You can check if two variables are the reference to the same parameter or object with the method .is()
  54. else if(param.is(myEnumParam)) {script.log("Key = "+param.getKey()+", data = "+param.get());} //The enum parameter has a special function getKey() to get the key associated to the option. .get() will give you the data associated
  55. else {script.log("Value is "+param.get());}; //All parameters have a get() method that will return their value
  56. }
  57. /*
  58. This function, if you declare it, will launch a timer at 50hz, calling this method on each tick
  59. */
  60. /*
  61. function update(deltaTime)
  62. {
  63. script.log("Update : "+util.getTime()+", delta = "+deltaTime); //deltaTime is the time between now and last update() call, util.getTime() will give you a timestamp relative to either the launch time of the software, or the start of the computer.
  64. }
  65. */
  66. /* ********** MODULE SPECIFIC SCRIPTING **********************
  67. The "local" variable refers to the object containing the scripts. In this case, the local variable refers to the module.
  68. It means that you can access any control inside this module by accessing it through its address.
  69. For instance, if the module has a float value named "Density", you can access it via local.values.density
  70. Then you can retrieve its value using local.values.density.get() and change its value using local.values.density.set()
  71. */
  72. /*
  73. This function will be called each time a parameter of this module has changed, meaning a parameter or trigger inside the "Parameters" panel of this module
  74. This function only exists because the script is in a module
  75. */
  76. function moduleParameterChanged(param)
  77. {
  78. if(param.isParameter())
  79. {
  80. script.log("Module parameter changed : "+param.name+" > "+param.get());
  81. }else
  82. {
  83. script.log("Module parameter triggered : "+param.name);
  84. }
  85. }
  86. /*
  87. This function will be called each time a value of this module has changed, meaning a parameter or trigger inside the "Values" panel of this module
  88. This function only exists because the script is in a module
  89. */
  90. function moduleValueChanged(value)
  91. {
  92. if(value.isParameter())
  93. {
  94. script.log("Module value changed : "+value.name+" > "+value.get());
  95. }else
  96. {
  97. script.log("Module value triggered : "+value.name);
  98. }
  99. }