-- flash a channel in lighting and restore to level in cue
-- run on hotkey / MIDI / OSC trigger
-- uses awk via shell script to parse the ligthing command of cue
-- define the channel to flash, the time and flash level
set ch to 1
set flashTime to 0.3
set flashLevel to 100
-- we know that ch 1 is a dimmer, so only has intensity parameter
set mySelector to ch
tell application id "com.figure53.QLab.5" to tell front workspace
-- get the cue at the playhead ..
set pendingCue to playhead of current cue list
-- move back until we find a lighting cue [WARNING: this will loop forever if no previous light cue!]
movePlayheadUp
repeat until (q type of playhead of current cue list as string is "Light")
movePlayheadUp
-- TODO put a break of this looping forever if no previous light cues
end repeat
set lightCue to playhead of current cue list
set cueLevel to my getLightLevel(command text of lightCue, mySelector)
-- display dialog (command text of myCue) & linefeed & "in cue " & (q number of myCue) & " ch " & mySelector & " level is " & cueLevel with title "debug light command and level"
-- TODO use multiple selectors for RGB fixtures
setLight current light dashboard selector mySelector value flashLevel
delay flashTime
setLight current light dashboard selector mySelector value cueLevel
-- reset the playhead (and hope the operator hasn't pressed go in the meantime!)
set playhead of current cue list to pendingCue
end tell
-- really need a getLight function but doesn't exist
on getLightLevel(lxcmd, mySelector)
-- return the level for given light selector
-- a light selector is a channel number and parameter (eg 32.red or just channel number for dimmer/intensity only channels)
set scpt to "echo \"" & lxcmd & "\" | awk -F= '$1~/" & mySelector & "/ {print $2}'"
return (do shell script scpt)
end getLightLevel
-- flash a light and revert to level in (previous run) light cue, v2
-- put this script on hotkey / MIDI / OSC trigger
-- uses awk via shell script to parse the ligthing command of cue
-- define the default channel to flash
set ch to 1
-- ask the user to enter the selector/channel to flash (comment this out if not needed)
set ch to text returned of (display dialog "Enter channel or selector " default answer ch with title "Flash Light Channel")
-- adjust these to suit
set flashTime to 0.3
set flashLevel to 100
-- we assume that ch is a dimmer, so only has intensity parameter
set mySelector to ch
tell application id "com.figure53.QLab.5" to tell front workspace
-- get the cue at the playhead ..
set pendingCue to playhead of current cue list
set MyCueList to current cue list
-- get the id of the first cue in the list to check when we reach the top of the list
-- (note the first item of cues whose parent is the cue list itself; so we want the second item)
set firstCueId to uniqueID of second item of ((cues whose parent list is MyCueList) as list)
set qtype to "Light"
movePlayheadUp
-- move the playhead up until we find a Light cue or until we reach the first cue in the list
repeat until (q type of playhead of MyCueList as string is qtype or uniqueID of (playhead of MyCueList) is equal to firstCueId)
movePlayheadUp
end repeat
-- check we've found a light cue
if q type of playhead of MyCueList as string is qtype then
set lightCue to playhead of current cue list
-- TODO try use multiple selectors for RGB fixtures
set cueLevel to my getLightLevel(command text of lightCue, mySelector)
setLight current light dashboard selector mySelector value flashLevel
delay flashTime
setLight current light dashboard selector mySelector value cueLevel
else
display notification qtype & " cue not found - nothing to do"
end if
-- reset the playhead (and hope the operator hasn't pressed go in the meantime!)
set playhead of current cue list to pendingCue
end tell
on getLightLevel(lxcmd, mySelector)
-- return the level for given light selector
-- a light selector is a channel number and parameter (eg 32.red or just channel number for dimmer/intensity only channels)
set scpt to "echo \"" & lxcmd & "\" | awk -F' = ' '$1~/^" & mySelector & "$/ {print $2}'"
-- display dialog scpt with title "Shell Script"
return (do shell script scpt)
end getLightLevel