(LUA) FlipFlop levels

Open Source software contributions and discussions that supplement or extend the Palette / Light Palette software
Post Reply
User avatar
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:

(LUA) FlipFlop levels

Post by RobertBell » Thu Jun 12, 2008 2:15 pm

If you ever have to take a bunch of fixtures that were at a level to zero and the ones at zero to the level, it can get quite boring, even with the REMDIM and SELECT INVERT tools. Try this one:

Code: Select all

s = HC.GetCurrentSelectionSet(',')
-- find the max value
newhigh = 0
for fixture in string.gmatch(s,"%d+") do
  if tonumber(HC.AttributeGetValue(fixture)) > newhigh then
   newhigh = tonumber(HC.AttributeGetValue(fixture))
  end
end
-- flip flop
for fixture in string.gmatch(s,"%d+") do
  if tonumber(HC.AttributeGetValue(fixture)) > 0 then
   HC.SetLevel(fixture,0)
  else
   HC.SetLevel(fixture,math.floor(2.55*newhigh))
  end
end
Robert Bell - Product Manager - Horizon Control Inc.

User avatar
gooze
Posts: 1760
Joined: Tue Dec 18, 2007 12:42 pm
Location: Amsterdam, The Netherlands
Contact:

Re: (LUA) FlipFlop levels

Post by gooze » Mon Aug 03, 2009 10:10 am

10.6.2001 I get an error while testing the script in the editor.
Floriaan Ganzevoort - Lighting designer
THEATERMACHINE design. production. operations.

User avatar
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) FlipFlop levels

Post by RobertBell » Tue Aug 04, 2009 4:54 pm

The error text would help here, but I figured it out - same as your other issue (I just posted):

Code: Select all

    s = HC.GetCurrentSelectionSet(',')
    -- find the max value
    newhigh = 0
    for fixture in string.gmatch(s,"%d+") do
      if tonumber(HC.AttributeGetValue(fixture,'intensity+V')) > newhigh then
       newhigh = tonumber(HC.AttributeGetValue(fixture,'intensity+V'))
      end
    end
    -- flip flop
    for fixture in string.gmatch(s,"%d+") do
      if tonumber(HC.AttributeGetValue(fixture,'intensity+V')) > 0 then
       HC.SetLevel(fixture,0)
      else
       HC.SetLevel(fixture,math.floor(2.55*newhigh))
      end
    end
Robert Bell - Product Manager - Horizon Control Inc.

User avatar
MickCrozier
Posts: 288
Joined: Tue Mar 31, 2009 3:10 am
Primary Venue / Use: Professional Theatre
Where I Am: Melbourne, Australia
Location: Melbourne, Australia

Re: (LUA) FlipFlop levels

Post by MickCrozier » Wed Sep 02, 2009 4:47 am

Take 3 - Fixed value decrease on repeated hits

Code: Select all

    s = HC.GetCurrentSelectionSet(',')
    -- find the max value
    newhigh = 0
    for fixture in string.gmatch(s,"%d+") do
      if tonumber(HC.AttributeGetValue(fixture,'intensity+V')) > newhigh then
       newhigh = tonumber(HC.AttributeGetValue(fixture,'intensity+V'))
      end
    end
    -- flip flop
    for fixture in string.gmatch(s,"%d+") do
      if tonumber(HC.AttributeGetValue(fixture,'intensity+V')) > 0 then
         HC.AttributeFade(fixture,0)
      else
         HC.AttributeFade(fixture,newhigh)
      end
    end
Formerly Durisian (who died peacefully of digital old age)

Post Reply