DMXlyre.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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, 41); // ROTATING GOBO
  23. local.send(10,13); // GOBO ROTATION
  24. }
  25. function float2DMX(value){
  26. value = Math.floor(value * 65535);
  27. var MSB = value / 256;
  28. var LSB = value % 256;
  29. return [ MSB , LSB];
  30. }
  31. function scriptParameterChanged(param)
  32. {
  33. if(param.is(pan_DMX)){
  34. var values = float2DMX(param.get());
  35. local.send(1, values[0]);
  36. local.send(3, values[1]);
  37. }
  38. if(param.is(tilt_DMX)){
  39. var values = float2DMX(param.get());
  40. local.send(2, values[0]);
  41. local.send(4, values[1]);
  42. }
  43. if(param.is(zoom_DMX)){local.send(14, param.get()*255);}
  44. if(param.is(focus_DMX)){local.send(13, param.get()*255);}
  45. if(param.is(dimmer_DMX)){local.send(6, param.get()*255);}
  46. if(param.is(defaultTrigger)){defaultState();}
  47. //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.
  48. script.log("Parameter changed : "+param.name); //All parameters have "name" property
  49. 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()
  50. 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
  51. else script.log("Value is "+param.get()); //All parameters have a get() method that will return their value
  52. }
  53. /*
  54. This function, if you declare it, will launch a timer at 50hz, calling this method on each tick
  55. */
  56. /*
  57. function update(deltaTime)
  58. {
  59. 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.
  60. }
  61. */
  62. /* ********** MODULE SPECIFIC SCRIPTING **********************
  63. The "local" variable refers to the object containing the scripts. In this case, the local variable refers to the module.
  64. It means that you can access any control inside this module by accessing it through its address.
  65. For instance, if the module has a float value named "Density", you can access it via local.values.density
  66. Then you can retrieve its value using local.values.density.get() and change its value using local.values.density.set()
  67. */
  68. /*
  69. 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
  70. This function only exists because the script is in a module
  71. */
  72. function moduleParameterChanged(param)
  73. {
  74. if(param.isParameter())
  75. {
  76. script.log("Module parameter changed : "+param.name+" > "+param.get());
  77. }else
  78. {
  79. script.log("Module parameter triggered : "+param.name);
  80. }
  81. }
  82. /*
  83. 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
  84. This function only exists because the script is in a module
  85. */
  86. function moduleValueChanged(value)
  87. {
  88. if(value.isParameter())
  89. {
  90. script.log("Module value changed : "+value.name+" > "+value.get());
  91. }else
  92. {
  93. script.log("Module value triggered : "+value.name);
  94. }
  95. }