Macro Editor & Scripts

The Lua Language

Advanced scripting in Marquee uses the Lua programming language and can be constructed to execute very complex routines that access the Processor's operating system, file system or other external non-lighting related devices. Lua is a full featured programming language that offers IF THEN ELSE type routines as well as user definable functions, string manipulation and local and global variable storage.

If you just want to run cues or control your media player or Power Point, you can, but do not need to use Scripts. Common tasks can be achieved using simple Macro Commands.

This topic can never cover the extensiveness of what Lua has to offer. It is a very mature language that has a avid group of uses easily found on the web. To describe Lua a little more succinctly, we took this from www.lua.org:

Lua combines simple procedural syntax with powerful data description constructs based on associative arrays and extensible semantics. Lua is dynamically typed, interpreted from bytecodes, and has automatic memory management with garbage collection, making it ideal for configuration, scripting, and rapid prototyping.

The HC Library

To make Lua capable of doing more than setting Variables in Marquee, we've extended the language buy writing a specific Horizon Control library that talks directly with Marquee's fade engine. All variables and library calls in Lua are case sensitive, so we've made it easy by providing you a list of available macros calls right in the editor:

Below is a list of available calls to the HC library. You will find that many of the routines are almost exactly like the common Macro Commands, but the syntax is slightly different. There are also some calls here that are not available as Commands.

 

Cue List Execution

HC.CueListGo('cue list')  

HC.CueListHaltBack('cue list')   

HC.CueListHalt('cue list')   

HC.CueListRelease('cue list')  

HC.CueListAssert('cue list')  

HC.CueListGotoAndHalt('cue list', cue)  

HC.CueListGotoAndExecuteFollows('cue list', cue)  

 

Power Point Automation

HC.PowerPointFirstSlide(machine_id)  

HC.PowerPointLastSlide(machine_id)  

HC.PowerPointPrevSlide(machine_id)  

HC.PowerPointNextSlide(machine_id)  

HC.PowerPointGotoSlide(machine_id,slide_number)  

 

Media Player Automation

HC.MediaPlayerPlay  

HC.MediaPlayerStop  

HC.MediaPlayerPause  

HC.MediaPlayerPlayFile('file name')  

Show Control

HC.SerialOpen(1 to 16,'9600,N,8,1'[,'script'])

HC.SerialClose(1 to 16)

HC.SerialWrite(1 to 16,'output string')

HC.SerialRead(1 to 16)

HC.MidiNoteOff(channel_1_to_16,key_1_to_128[,velocity_0_to127])

HC.MidiNoteOn(channel_1_to_16,key_1_to_128[,velocity_0_to127])

HC.MidiWrite(midi_byte[,midi_byte ...])

HC.SMPTEStart(['hh:mm:ss.fr'[,'30'|'30dr'|'25'|'24']][,interface]) (note: Internal SMPTE 1 through 4 are interfaces 101 through 104)

HC.SMPTEStop(interface)

ILS Commands

HC.ILSSetScene(device_id,scene)

HC.ILSLockCommand(device_id,lock(1)/unlock(0)

Hardware Setup

HC.HardwareConsoleLights(level 0 to 10)  

 

Fixture Check Automation

HC.FixtureCheckForward

HC.FixtureCheckBack  

Variable Manipulation

HC.VariableGet('page','name' or order)  

HC.VariableSet('page','name' or order,'value' or value)

HC.VariableSetDelayed('page','name' or order,'value' or value,seconds)  

HC.GetScriptSource('type'|'number'|'parent'|'name'[,'type'|'number'|'parent'|'name'[,'seperator']])  

Strings

HC.Status('status string')

HC.GetScriptSource('type'|'number'|'parent'|'name'[,'type'|'number'|'parent'|'name'[,'seperator']])  

 

Look Master Automation

HC.LookFade('page',looknumber,value[,seconds])  

HC.LookFadeRate('page',looknumber,value[,seconds full scale])  

HC.LookFadeStop('page',looknumber)  

HC.LookGetValue('page',looknumber)  

 

Attribute Manipulation

HC.AttributeGetValue(fixture[,attribute_name])  

HC.AttributeFade(fixture[,attribute_name],value [,time])  

Automation

HC.PatchFixture(fixture[,intensity_dmx][,attribute_dmx,'manufacturer','model']

HC.RecordLook('look_page',look_number[,'merge'|'replace'][,'IPCGLSTE'][,'label)

HC.RecordCue('cue_list',cue_number[,'merge'|'replace'][,'IPCGLSTE'][,cue_time][,'label'])

HC.ReleaseAll()

HC.UIMacro('macro-info'[,'macro-info' ...])

 

Below are a few examples to get you started writing Lua scripts in Marquee quickly. Much more detailed examples and documentation of the language can be found on-line.

Example - Raise Lower on Architectural Button Station

One of the common button stations to have in an architectural installation is a 6-button scene set (On, Off, plus four scenes). These button stations also have a Raise/Lower rocker button. Making buttons 1 through 6 part of the same radio group, each fading in a look on the Button Down action, then fading it out on the Button Up action makes for an easy preset selection. Where it becomes a bit more tricky is utilizing the Raise/Lower buttons. The following code determines the currently selected scene, then applies a fade using a predetermined rate to raise and lower the current look. This code shows the actions you would put on the Raise button. Similar code would be put on the Lower buttons using HC.LookFadeRate('Main',CurBut,0,5) rather than the third parameter being 100 as shown below.

-- RAISE BUTTON DOWN ACTION

-- make global variable CurBut invalid

CurBut = -1

-- loop through first 5 buttons to see which one is down

for i =  1, 5 do

   -- is button i down

   if HC.VariableGet('Hall',i) == 1 then  

     -- store away button number

     CurBut = i

   end

end

-- only do if button is valid

if CurBut ~= -1 then

   -- start a 5 sec. rate fade of the look on the current button

   HC.LookFadeRate('Main',CurBut,100,5)

end

 

-- RAISE BUTTON UP ACTION

-- only do if button is valid

if CurBut ~= -1 then

   -- stop the fade started in RAISE BUTTON code

   HC.LookFadeStop('Main',CurBut)

end

 

Example - Occupancy Sensor using File IO

This example shows how scripts can access the operating system's disk input and output routines.  All the Variables on this Variable Page have the same code and are tied to occupancy sensors, such that when the sensor is tripped, the macro is fired. The script finds out the name of the sensor that is tripped and writes the data to a log file.

-- Code for all sensors

-- opens file for appending

local f = io.open('d:\\People.log', 'a')

-- get variable name and write log file

f:write(HC.GetScriptSource('name') .. '\t was tripped at ' .. os.date('%X') ..

   ' on ' .. os.date('%x') ..'\n')

-- close the file so other applications can access it

f:close()

 

If you had four sensors, one in the Entrance, one at the Exit, one in the Theater and one in the Great Hall, the log file may look like this:

Entrance   was tripped at 11:11:37 on 05/15/06

Exit       was tripped at 11:11:51 on 05/15/06

Theater A  was tripped at 11:12:40 on 05/15/06

Great Hall was tripped at 11:15:52 on 05/15/06

Theater A  was tripped at 11:21:22 on 05/15/06

Exit       was tripped at 12:01:46 on 05/15/06

Entrance   was tripped at 12:22:17 on 05/15/06

 

 

Example - Temperature Indicator using Serial Port Communication

In this example an external temperature sensor is hooked to Marquee using one of the serial ports. At specific intervals, the current temperature is read and different cues are run to indicate to the public, using color or movement, the temperature. A Time Event with an hourly repeat executes this code:

-- open Com1: with proper parameters

HC.SerialOpen(1,'9600,N,8,1')

-- request temperature from gauge (hex code)

HC.SerialWrite(1,'0x4b')

 

A very short while later, (enough time for the gauge to respond) this code is called:

 

-- sucks in temperature as a string

temp = HC.SerialRead(1)

-- close serial port

HC.SerialClose(1)

-- converts the string 'temp' to a number (adding 20)

temp = temp + 20

-- limit the bottom (-20F will be the coldest)

temp = math.max(temp,0)

-- limit the top (110F will be the hottest)

temp = math.min(temp, 130)

-- normalize between 1 and 12 rounding down

cue = 1 + math.floor(temp * 11 / 130)

-- run the cue sequence

HC.CueListGotoAndExecuteFollows('Temperature', cue)

 

See Also

www.lua.org

Macro Editor and Commands

User Interface Macros

Macro Buttons

Time Events

Triggers

Cue Properties

Blue Box

PowerPoint Automation