Scripts

Millumin is able to execute JavaScript program to automate task on the computer, control software/hardware, get data from Internet, react to Millumin’s events …


Run your first Script

A script can be created from the + button of the library:


The created script can be found in the Scripts group of the library:


Then, add this script to a layer and run it : the small light-icon remains green until the script finished. If your script is listening for some event, it could run endlessly, but you can stop it.


Of course, you can edit your script to adjust it. Use the auto-completion to ease your job : type a few characters (Mil for example) to show the possibilities in terms of functions.


Be sure to check the provided templates, as they shows various abilities of the scripts (using different functions for different purposes) :


Functions

Control Millumin

These functions are prefixed by Millumin.
Exemple : Millumin.getLaunchedColumnName()
Here is the list :

  • Columns
    • getLaunchedColumnIndex()
    • getLaunchedColumnName()
    • launchColumn(indexOrName)
    • launchOrStopColumn(indexOrName)
    • stopColumn()
    • launchPreviousColumn()
    • launchNextColumn()
    • getColumnDuration(indexOrName)
    • getColumnElapsedTime(indexOrName)
    • getColumnRemainingTime(indexOrName)
  • Play
    • play()
    • pause()
    • playOrPause()
    • goToTime(time)
    • goToTimelineSegment(name)
  • Selection
    • getCurrentBoardIndex()
    • getCurrentBoardName()
    • selectBoard(indexOrName)
    • selectLayer(indexOrName)
    • selectLight(indexOrName)
  • Masters
    • setMasterVideo(value)
    • setMasterAudio(value)
    • setMasterDMX(value)
  • Brush
    • setBrush(x, y, pressure)
  • Project
    • getCanvasSize(name)
    • enterFullscreen()
    • exitFullscreen()
    • displayTestCard()
    • hideTestCard()
    • enableWorkspace()
    • disableWorkspace()
    • openProject(path)
    • saveProject(nullOrPath)
    • quit()
  • Light
    • getLightIntensity(indexOrName)
    • setIntensity(indexOrName, value)
  • Layer
    • getLayerPosition(indexOrName)
    • setLayerPosition(indexOrName, x, y)
    • getLayerSize(indexOrName)
    • getLayerOpacity(indexOrName)
    • setLayerOpacity(indexOrName, value)
    • getLayerScale(indexOrName)
    • setLayerScale(indexOrName, value)
    • getLayerRotation(indexOrName)
    • setLayerRotation(indexOrName, value)
    • getLayerMapping(indexOrName)
    • setLayerMapping(indexOrName, arrayOfPoints)
  • Media
    • getLayerMediaName(indexOrNameOfLayer)
    • getLayerMediaTime(indexOrNameOfLayer)
    • setLayerMediaTime(indexOrNameOfLayer, time)
    • getLayerMediaNormalizedTime(indexOrNameOfLayer)
    • setLayerMediaNormalizedTime(indexOrNameOfLayer, value)
    • getLayerMediaSpeed(indexOrNameOfLayer)
    • setLayerMediaSpeed(indexOrNameOfLayer, value)
    • getLayerMediaText(indexOrNameOfLayer)
    • setLayerMediaText(indexOrNameOfLayer, text)
    • restartLayerMedia(indexOrNameOfLayer)
    • pauseLayerMedia(indexOrNameOfLayer)
    • restartOrPauseLayerMedia(indexOrNameOfLayer)
    • stopLayerMedia(indexOrNameOfLayer)
    • startMedia(indexOrNameOfLayer, indexOrNameOfMedia)
    • getMediaProperty(indexOrNameOfLayer, indexOrNameOfMedia, propertyName)
    • setMediaProperty(indexOrNameOfLayer, indexOrNameOfMedia, propertyName, value)
    • importMedia(pathOrMediaName, indexOrNameOfLayer, nullOrIndexOrNameOfColumn, startImmediately)
    • removeMedia(indexOrNameOfLayer, indexOrNameOfColumn)
  • Effects
    • getEffectProperty(indexOrNameOfLayer, indexOrNameOfEffect, propertyName)
    • setEffectProperty(indexOrNameOfLayer, indexOrNameOfEffect, propertyName, value)
  • Data (commands are the same as for the data-track)
    • sendMIDI(nullOrDestination, command)
    • sendOSC(senderNameOrAddressPort, command)
    • sendDMX(senderName, command)
    • sendString(senderNameOrAddressPort, command)
  • Interactions (when the script is launched via an interaction)
    • getInteractionValue()

Events

These functions are prefixed by on, suffixed by Event and always takes the event parameter (a dictionary containing various infos).

  • onBlobTrackerEvent(event)
  • onArtnetEvent(event)
  • onDMXEvent(event)
  • onElectronicDeviceEvent(event)
  • onGamePadEvent(event)
  • onInternalSignalEvent(event)
  • onKeyboardEvent(event)
  • onKinectEvent(event)
  • onKinect2Event(event)
  • onLeapMotionEvent(event)
  • onMIDIEvent(event)
  • onOSCEvent(event)
  • onSACNEvent(event)
  • onSkeletonTrackerEvent(event)
  • onTimecodeEvent(event)
     
  • onMilluminEvent(event)
    This is a special event reflecting changes in Millumin.
    The parameter is a dictionary containing :
    - the name of the event : a string like elementUpdated, launchedColumn, stoppedColumn, masterChanged, layerSelected or lightSelected
    - the path : an array of strings explaining how to access the related object (for example the name of the board or the path to the layer’s property)
    - some values : for example the index/name of the column or the value of the layer’s property

Graphics

These functions allow to draw content.
They are prefixed by Graphics.

  • setSize(width, height)
  • setFramerate(fps)
  • fillBackground("#55AAFF99")
  • drawLine(x1, y1, x2, y2, thickness, "#FFFF00")
  • fillRect(x, y, width, height, "#FFFF00")
  • drawRect(x, y, width, height, thickness, "#FFFF00”)
  • fillEllipse(x, y, width, height, "#FFFF00")
  • drawEllipse(x, y, width, height, thickness, "#FFFF00")
  • drawText("text", x, y, size, "#FFFF00")

Parameter

These functions create parameters in the properties-view.
They are prefixed by Parameter.

  • createParameter("name", defaultValue, isInteger, bounds)
  • createParameter("my number", 1.23)
  • createParameter("my month", 1, true, [1,12])
  • createParameter("my boolean", false)
  • createParameter("my string", "defaultValue")
  • createParameterAsList("name", "item1", ["item1","item2","item3"])
  • createButton("name", function() {log("ok")} )
  • addInfo("description")
  • addSpace()
  • get("name")
  • set("name", value)
  • refreshList()

Network

These functions allow to create TCP/UDP servers and listeners.
They are prefixed by Network.

  • sendTCPRequest(request, ip, port)
  • listenTCP(port, callback)
  • stopListenTCPOnPort(port)
  • sendUDPRequest(request, ip, port)
  • listenUDP(port, callback)
  • stopListenUDPOnPort(port)

System

These do not have any prefix :

  • log(message)
  • setTimeout(callback, ms)
  • setInterval(callback, ms)
  • clearTimeout(timeout)
  • runCommand(command)
  • runAppleScript(script)
  • loadJSLibrary(url)
  • getFileContents(path)
  • getURLContents(url)
  • getFileBinaryData(path)
  • getURLBinaryData(url)
  • writeFileContents(path, contents)

Interaction

If you prefer to run your script via an interaction, it is also possible.
Simply open the Interaction panel (CMD+M), create an interaction and choose the action Run Script :


This is very handy to create a shortcut for a specific set of actions in your project. And you can the function Millumin.getInteractionValue() to get the value used by the interaction.

Code Snippets

To get inspiration, have a look to the examples embed in Millumin : these will show you how to animate, send data, load external content, use a Javascript library, execute AppleScript, …


Other examples :

function update()
{
    counter++
    log(counter+" seconds")
    if( 3 <= counter )
    {
        clearTimeout(timeout)
    }
}
counter = 0;
timeout = setInterval(update, 1000)
result = runCommand("ls ~/Desktop")
log("LIST OF DESKTOP FILES\n\n"+result)
contents = getURLContents("https://en.wikipedia.org/w/api.php?format=json&action=query&prop=extracts&exlimit=max&explaintext&titles=Ray_Bradbury")
json = JSON.parse(contents)
pages = json["query"]["pages"]
pageID = Object.keys(pages)[0];
log(pages[pageID]["extract"])

Examples to send data (see also templates in this article Data-track ) :

Millumin.sendMIDI(null, "NOTE 24 @ 121")
Millumin.sendMIDI("Bus 1", "CC 7/24 @ 121")
Millumin.sendOSC("192.168.0.38:7001", "/message 0.2 'string'")
Millumin.sendDMX("sACN", "C12@U3 @ 45")
Millumin.sendDMX("Artnet", "C12 @ 34")
Millumin.sendString("192.168.0.38:7001", "string")


   Follow Us

   Facebook
   Instagram
   Youtube
   Group



   Submit your Idea

If you need something, feel free to submit an idea.
Indeed, it helps us to keep track of user requests, and see their popularity.



  Ask your Question