Lua ??? - Record, fade selection
- TaineGilliam
- Posts: 1186
- Joined: Tue Oct 23, 2007 5:15 pm
- Location: Cleveland, OH
- Contact:
Lua ??? - Record, fade selection
For HC.Record(), how do I specify Record Type (Live, Delta, Selected).
Secondly, is there shortcut syntax for HC.AttributeFade() for current selection? For example to set the entire selection to 50% intensity...
Secondly, is there shortcut syntax for HC.AttributeFade() for current selection? For example to set the entire selection to 50% intensity...
- RobertBell
- Posts: 2421
- Joined: Fri Oct 12, 2007 1:11 pm
- Primary Venue / Use: Other
- Where I Am: Horizon Control Inc
- Location: On the dark side just north of Toronto
- Contact:
Re: Lua ??? - Record, fade selection
I currently don't thing there is a method. Sorry.TaineGilliam wrote:For HC.Record(), how do I specify Record Type (Live, Delta, Selected).
TaineGilliam wrote:Secondly, is there shortcut syntax for HC.AttributeFade() for current selection? For example to set the entire selection to 50% intensity...
Code: Select all
s = HC.GetCurrentSelectionSet(',')
for fixture in string.gmatch(s,"%d+") do
HC.AttributeFade(fixture,50)
end
Robert Bell - Product Manager - Horizon Control Inc.
- TaineGilliam
- Posts: 1186
- Joined: Tue Oct 23, 2007 5:15 pm
- Location: Cleveland, OH
- Contact:
Re: Lua ??? - Record, fade selection
Thanks for the ideas. I assume, since I can't set the type of record for Lua it uses the Show default?
Also, I'm having a bit of trouble with the script below. I seems to run and creates all ten cues but each cue only contains three channels are zero. and the MessageBox only appears once with "Cue = 10". I'm triggering this from an Action Momentary Bump button (right click in the OLE actually).
The idea here is to create some "random" cues from the selection to be used with the new Cue List types Robert described with 10.6.1.
Also, I'm having a bit of trouble with the script below. I seems to run and creates all ten cues but each cue only contains three channels are zero. and the MessageBox only appears once with "Cue = 10". I'm triggering this from an Action Momentary Bump button (right click in the OLE actually).
The idea here is to create some "random" cues from the selection to be used with the new Cue List types Robert described with 10.6.1.
Code: Select all
NumCues = 10 -- How many cues are we making
NumCells = 3 -- How many fixtures on per cue
CueListName = 'Demo' -- name of the Cue list to store the cue in
-- Build an array of the fixture numbers
-- FixSel will be that Array
-- NumFixtures will be the number of fixtures in the array
NumFixtures=0
Pos1=1
FixSel={}
FixSel[0]=HC.GetCurrentSelectionSet(',')
for x = 1,string.len(FixSel[0]) do
FindCom=string.find(FixSel[0],',',Pos1)
if FindCom~=nil then
NumFixtures=NumFixtures+1
FixSel[NumFixtures]=string.sub(FixSel[0],Pos1,FindCom-1)
Pos1=FindCom+1
end
end
FirstFixture=FixSel[1]
LastFixture=FixSel[NumFixtures]
HC.Status(NumFixtures)
math.randomseed( os.time() )
for x = 1, NumCues do
HC.ReleaseAll()
for y = 1, NumCells do
val = math.random(NumFixtures)
HC.AttributeFade(FixSel[val], 'Intensity', 100)
end
HC.MessageBox('Cue=' .. x)
HC.RecordCue(CueListName,x)
end
- RobertBell
- Posts: 2421
- Joined: Fri Oct 12, 2007 1:11 pm
- Primary Venue / Use: Other
- Where I Am: Horizon Control Inc
- Location: On the dark side just north of Toronto
- Contact:
Re: Lua ??? - Record, fade selection
I have not done it either. I think there is a problem with AttributeFade or SetLevel working inside of a for loop.
I did things very different (for you) but still got the hard zeros.
So - problem 1 - HC.SetLevel(aFixture,255) or HC.AttributeFade(aFixture,50) or your HC.AttributeFade(aFixture, 'Intensity', 100) are not working inside the for loop. We've confirmed that the record macro is only recording deltas and after each record (in my show file) they are released - you no need to call ReleaseAll()
I am also having a problem (problem 2) on line 15
It seems that if NumCues or NumCells is too large, after 7 or so cues, the list l is empty (we do remove items - but I figured each call to this routine would out-scope the last l. There may be a problem with stale l's. This error is very hard to debug as my print(gothere)'s get blown off by the error msg itself. Even if I put the random call in an assert() - the error msg obliterates my print() statements.
I'll have Gary and Alan look at this.
I did things very different (for you) but still got the hard zeros.
So - problem 1 - HC.SetLevel(aFixture,255) or HC.AttributeFade(aFixture,50) or your HC.AttributeFade(aFixture, 'Intensity', 100) are not working inside the for loop. We've confirmed that the record macro is only recording deltas and after each record (in my show file) they are released - you no need to call ReleaseAll()
Code: Select all
NumCues = 6 -- How many cues are we making
NumCells = 2 -- How many fixtures on per cue
CueListName = 'A' -- name of the Cue list to store the cue in
function RandomSelection(l, samp)
local newlist
newlist = {}
if not samp then
samp = 0
else
samp = #l - samp
end
while #l > samp do
local idx
idx = math.random(1, #l)
newlist[#newlist + 1] = l[idx]
table.remove(l, idx)
end
return newlist
end
allfixtures = {} -- in current selection set
s = HC.GetCurrentSelectionSet(',')
for aFixture in string.gmatch(s,"%d+") do
table.insert(allfixtures ,aFixture)
end
if #allfixtures <= NumCells then
HC.MessageBox('Selection set too small')
else -- write the cues
for x = 1, NumCues do
JustSome = RandomSelection(allfixtures,NumCells)
table.foreach(JustSome,
function(key,aFixture)
HC.SetLevel(aFixture,255)
end
) -- end table.foreach
HC.RecordCue(CueListName,x)
end -- cue writting loop
end
Code: Select all
Call error: [string ""]:15: bad argument #2 to 'random' (interval is empty)
I'll have Gary and Alan look at this.
Robert Bell - Product Manager - Horizon Control Inc.
- RobertBell
- Posts: 2421
- Joined: Fri Oct 12, 2007 1:11 pm
- Primary Venue / Use: Other
- Where I Am: Horizon Control Inc
- Location: On the dark side just north of Toronto
- Contact:
Re: Lua ??? - Record, fade selection
FYI Gary and Alan - I changed the show file options to NOT REL ON REC and NOT GOTO ON REC as I know if those things are being done, then we're taking more than one cycle to do that and the macro should have run out of time. I still got hard zeros.
Also - I'm not seeing the LUA TIMEOUT log report in system.log (although - I've never seen it or tested it so I don't know what it looks like).
Also - I'm not seeing the LUA TIMEOUT log report in system.log (although - I've never seen it or tested it so I don't know what it looks like).
Robert Bell - Product Manager - Horizon Control Inc.
- RobertBell
- Posts: 2421
- Joined: Fri Oct 12, 2007 1:11 pm
- Primary Venue / Use: Other
- Where I Am: Horizon Control Inc
- Location: On the dark side just north of Toronto
- Contact:
Re: Lua ??? - Record, fade selection
NO - it is Always Delta.TaineGilliam wrote:I assume, since I can't set the type of record for Lua it uses the Show default?
Robert Bell - Product Manager - Horizon Control Inc.
- RobertBell
- Posts: 2421
- Joined: Fri Oct 12, 2007 1:11 pm
- Primary Venue / Use: Other
- Where I Am: Horizon Control Inc
- Location: On the dark side just north of Toronto
- Contact:
Re: Lua ??? - Record, fade selection
OK - I talked to Alan. There is a fade resolution problem with trying to do a lot of AttributeFades()'s and Record()'s in one lua loop. The thought is we may overload those functions to work in blind and then we can do as much as we want in one lua cycle.
The other thing I researched and learnt this morning is that lua tables are always passed ByRef vs. other variables passed (traditionally) ByVal.
So - before passing the large group of fixtures into the randomizer, we copy the table using the code found here: http://lua-users.org/wiki/CopyTable
Apart from the level set bug which we have no solution for today - this is working
The other thing I researched and learnt this morning is that lua tables are always passed ByRef vs. other variables passed (traditionally) ByVal.
So - before passing the large group of fixtures into the randomizer, we copy the table using the code found here: http://lua-users.org/wiki/CopyTable
Apart from the level set bug which we have no solution for today - this is working
Code: Select all
NumCues = 6 -- How many cues are we making
NumCells = 2 -- How many fixtures on per cue
CueListName = 'A' -- name of the Cue list to store the cue in
function deepcopy(object)
local lookup_table = {}
local function _copy(object)
if type(object) ~= "table" then
return object
elseif lookup_table[object] then
return lookup_table[object]
end
local new_table = {}
lookup_table[object] = new_table
for index, value in pairs(object) do
new_table[_copy(index)] = _copy(value)
end
return setmetatable(new_table, getmetatable(object))
end
return _copy(object)
end
function RandomSelection(l, samp)
local newlist
newlist = {}
if not samp then
samp = 0
else
samp = #l - samp
end
while #l > samp do
local idx
idx = math.random(#l)
newlist[#newlist + 1] = l[idx]
table.remove(l, idx)
end
return newlist
end
allfixtures = {} -- in current selection set
s = HC.GetCurrentSelectionSet(',')
for aFixture in string.gmatch(s,"%d+") do
table.insert(allfixtures ,aFixture)
end
if #allfixtures <= NumCells then
HC.MessageBox('Selection set too small')
else -- write the cues
for x = 1, NumCues do
JustSome = RandomSelection(deepcopy(allfixtures),NumCells)
table.foreach(JustSome,
function(key,aFixture)
HC.AttributeFade(aFixture,50)
end
) -- end table.foreach
HC.RecordCue(CueListName,x)
end -- cue writting loop
end
Robert Bell - Product Manager - Horizon Control Inc.
- TaineGilliam
- Posts: 1186
- Joined: Tue Oct 23, 2007 5:15 pm
- Location: Cleveland, OH
- Contact:
Re: Lua ??? - Record, fade selection
Thanks for digging into this. I'll need to study your code a bit to really see what you have done. I'm not sure why we need to create the extra function calls and worry about the pass by ref/value issue. More study need on my part.
Doing it in sorta Blind would be great. It would be nice to get the selection from Live but have the "work" happen behind the scenes so to speak.
Gothcha's like the HC.Record() always does Deltas are the reason we need a HC.* reference page/manual/wiki...
I found the fact the MessageBox only appeared once to be a sign something really fishy was happening. I had only added the Message box as a debug tool and an attempt to slow down the loops to allow the console to catch up and it blew right past them. It looks like some of the call are asynch as opposed to "blocking" - probably a good thing in many case but catches us here.
As for the algorithm, I considered adding logic to only select once... but decided for the first round to keep it simple - Just Y number of fixtures from the selection at a level for each cue. It would be easy to swap the chosen item to the end of the FixSel array and reduce the NumFixtures for each iteration to force each fixture to be chosen only once. I also considered auto setting the number of fixtures per Cue based on the size of the selection and number of cues - this would make the "each fixture once" method safer.
Doing it in sorta Blind would be great. It would be nice to get the selection from Live but have the "work" happen behind the scenes so to speak.
Gothcha's like the HC.Record() always does Deltas are the reason we need a HC.* reference page/manual/wiki...
I found the fact the MessageBox only appeared once to be a sign something really fishy was happening. I had only added the Message box as a debug tool and an attempt to slow down the loops to allow the console to catch up and it blew right past them. It looks like some of the call are asynch as opposed to "blocking" - probably a good thing in many case but catches us here.
As for the algorithm, I considered adding logic to only select once... but decided for the first round to keep it simple - Just Y number of fixtures from the selection at a level for each cue. It would be easy to swap the chosen item to the end of the FixSel array and reduce the NumFixtures for each iteration to force each fixture to be chosen only once. I also considered auto setting the number of fixtures per Cue based on the size of the selection and number of cues - this would make the "each fixture once" method safer.
- RobertBell
- Posts: 2421
- Joined: Fri Oct 12, 2007 1:11 pm
- Primary Venue / Use: Other
- Where I Am: Horizon Control Inc
- Location: On the dark side just north of Toronto
- Contact:
Re: Lua ??? - Record, fade selection
Keep in mind - the lua stuff has to happen in one refresh cycle - so you can't interrupt it with msgboxes. And (FYI) the msgbox routine knows enough to kill any open msgboxes before trying to draw another. The msgbox in not MODAL (does not wait for an OK).
We're making a change today to stop the ERROR: messages in the output window blowing off previous print() statements. This will help make debugging easier and now when you get an error, that is all you see. (Point being - use print()s rather than msgboxes for debugging)
Getting selection from Live and working behind the scenes in Blind will be possible.
RE: Wiki - I went to our own Twiki to get your answer about arguments to Record(). There was none. The only documentation we have on it is what is in the script editor and those are self explanatory. I did post some of it here in the form of the attached PDF.
We're making a change today to stop the ERROR: messages in the output window blowing off previous print() statements. This will help make debugging easier and now when you get an error, that is all you see. (Point being - use print()s rather than msgboxes for debugging)
Getting selection from Live and working behind the scenes in Blind will be possible.
RE: Wiki - I went to our own Twiki to get your answer about arguments to Record(). There was none. The only documentation we have on it is what is in the script editor and those are self explanatory. I did post some of it here in the form of the attached PDF.
With the routine's I've given you, these changes would be very easy. It's all to do with selecting from that table and table.remove(item) and remembering for next time around the loop that #mytable returns the number of elements left in mytable.As for the algorithm, I considered adding logic to only select once... but decided for the first round to keep it simple - Just Y number of fixtures from the selection at a level for each cue. It would be easy to swap the chosen item to the end of the FixSel array and reduce the NumFixtures for each iteration to force each fixture to be chosen only once. I also considered auto setting the number of fixtures per Cue based on the size of the selection and number of cues - this would make the "each fixture once" method safer.
Robert Bell - Product Manager - Horizon Control Inc.
- TaineGilliam
- Posts: 1186
- Joined: Tue Oct 23, 2007 5:15 pm
- Location: Cleveland, OH
- Contact:
Re: Lua ??? - Record, fade selection
I had been using HC.Status() to put messages in the status box for debug. I didn't realize the MessageBox wouldn't wait for the user to close before moving on. I guess this greatly reduces the chance of getting a meaningful prompt and wait for user input dialog.
I'll read your code more closely once I'm back in the office. Thanks again.
Taine
I'll read your code more closely once I'm back in the office. Thanks again.
Taine