123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- var defaultTrigger = script.addTrigger("default","set DMX channels to default values");
- 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
- var tilt_DMX = script.addFloatParameter("tilt_DMX","tilt position",.1,0,1);
- var zoom_DMX = script.addFloatParameter("zoom_DMX","zoom position",.1,0,1);
- var focus_DMX = script.addFloatParameter("focus_DMX","pan position",.1,0,1);
- var dimmer_DMX = script.addFloatParameter("dimmer_DMX","light level",.1,0,1);
- function init()
- {
- //myFloatParam.set(5); //The .set() function set the parameter to this value.
- //myColorParam.set([1,.5,1,1]); //for a color parameter, you need to pass an array with 3 (RGB) or 4 (RGBA) values.
- //myP2DParam.set([1.5,-5]); // for a Point2D parameter, you need to pass 2 values (XY)
- //myP3DParam.set([1.5,2,-3]); // for a Point3D parameter, you need to pass 3 values (XYZ)
- }
- /*
- This function will be called each time a parameter of your script has changed
- */
- function defaultState(){
- local.send(7, 8); // STROBE
- local.send(12, 0); // PRISM
- local.send(8, 0); // COLOR
- local.send(11, 0); // STATIC GOBO
- local.send(9, 41); // ROTATING GOBO
- local.send(10,13); // GOBO ROTATION
- }
- function float2DMX(value){
- value = Math.floor(value * 65535);
- var MSB = value / 256;
- var LSB = value % 256;
- return [ MSB , LSB];
- }
- function scriptParameterChanged(param)
- {
- if(param.is(pan_DMX)){
- var values = float2DMX(param.get());
- local.send(1, values[0]);
- local.send(3, values[1]);
- }
- if(param.is(tilt_DMX)){
- var values = float2DMX(param.get());
- local.send(2, values[0]);
- local.send(4, values[1]);
- }
- if(param.is(zoom_DMX)){local.send(14, param.get()*255);}
- if(param.is(focus_DMX)){local.send(13, param.get()*255);}
- if(param.is(dimmer_DMX)){local.send(6, param.get()*255);}
- if(param.is(defaultTrigger)){defaultState();}
- //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.
- script.log("Parameter changed : "+param.name); //All parameters have "name" property
- 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()
- 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
- else script.log("Value is "+param.get()); //All parameters have a get() method that will return their value
- }
- /*
- This function, if you declare it, will launch a timer at 50hz, calling this method on each tick
- */
- /*
- function update(deltaTime)
- {
- 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.
- }
- */
- /* ********** MODULE SPECIFIC SCRIPTING **********************
- The "local" variable refers to the object containing the scripts. In this case, the local variable refers to the module.
- It means that you can access any control inside this module by accessing it through its address.
- For instance, if the module has a float value named "Density", you can access it via local.values.density
- Then you can retrieve its value using local.values.density.get() and change its value using local.values.density.set()
- */
- /*
- 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
- This function only exists because the script is in a module
- */
- function moduleParameterChanged(param)
- {
- if(param.isParameter())
- {
- script.log("Module parameter changed : "+param.name+" > "+param.get());
- }else
- {
- script.log("Module parameter triggered : "+param.name);
- }
- }
- /*
- 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
- This function only exists because the script is in a module
- */
- function moduleValueChanged(value)
- {
- if(value.isParameter())
- {
- script.log("Module value changed : "+value.name+" > "+value.get());
- }else
- {
- script.log("Module value triggered : "+value.name);
- }
- }
|