Page 1 of 1

(LUA) FlipFlop levels

Posted: Thu Jun 12, 2008 2:15 pm
by RobertBell
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

Re: (LUA) FlipFlop levels

Posted: Mon Aug 03, 2009 10:10 am
by gooze
10.6.2001 I get an error while testing the script in the editor.

Re: (LUA) FlipFlop levels

Posted: Tue Aug 04, 2009 4:54 pm
by RobertBell
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

Re: (LUA) FlipFlop levels

Posted: Wed Sep 02, 2009 4:47 am
by MickCrozier
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