From a47647789b4f76c2c03d44aa8f18c78ce3371c0f Mon Sep 17 00:00:00 2001 From: Ebbe Date: Sat, 26 Apr 2025 20:05:38 +0200 Subject: [PATCH] finished plugin Signed-off-by: Ebbe --- flimr-plugin.lua | 59 ++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 47 insertions(+), 12 deletions(-) diff --git a/flimr-plugin.lua b/flimr-plugin.lua index b25dbf0..c2e2c8e 100644 --- a/flimr-plugin.lua +++ b/flimr-plugin.lua @@ -6,36 +6,71 @@ local function debug_print(message) end end +local function split_first(inputstr, sep) + local sep = sep or ";" + local sep_pos = string.find(inputstr, sep) + if not sep_pos then + return inputstr, nil + end + local first = string.sub(inputstr, 1, sep_pos - 1) + local rest = string.sub(inputstr, sep_pos + 1) + return first, rest +end + local function update_groups() debug_print("Updating groups based of tags.") end local function setOVR(channel, argument) - if type(argument) == "number" then - Cmd('Store Group '..argument..' at Group "CASP_OVR Channel '..channel..'" /Overwrite') - debug_print("Updated CASP_OVR Channel "..channel.." to Group "..argument) + if type(tonumber(argument)) == "number" then + Cmd('SelectFixture Group '..argument) + Cmd('Store Group "CASP_OVR Channel '..channel..'" /Overwrite') + Cmd("ClearSelection") + debug_print("NUM: Updated CASP_OVR Channel "..channel.." to Group "..argument) elseif type(argument) == "string" then - Cmd('Store Group "'..argument..'" at Group "CASP_OVR Channel '..channel..'" /Overwrite') - debug_print("Updated CASP_OVR Channel "..channel.." to Group "..argument) + Cmd('SelectFixture Group "'..argument..'"') + Cmd('Store Group "CASP_OVR Channel '..channel..'" /Overwrite') + Cmd("ClearSelection") + debug_print("STR: Updated CASP_OVR Channel "..channel.." to Group "..argument) end end +local function clearAllOVR() + for channel = 1, 5/1, 1 do + Cmd('SelectFixture Group "CASP_OVR Channel '..channel..'"') + Cmd('Store Group "CASP_OVR Channel '..channel..'" /Remove') + Cmd("ClearSelection") + end +end + +local function clearOVR(channel) + Cmd('SelectFixture Group "CASP_OVR Channel '..channel..'"') + Cmd('Store Group "CASP_OVR Channel '..channel..'" /Remove') + Cmd("ClearSelection") +end + local function main(display_handle, args) if args then if string.match(args, ";") then - local operator, argument = args.partition(";") - if operator == "set_OVR_C1" then + local operator, argument = split_first(args, ";") + if operator == "setOVRC1" then setOVR(1, argument) - elseif operator == "set_OVR_C2" then + elseif operator == "setOVRC2" then setOVR(2, argument) - elseif operator == "set_OVR_C3" then + elseif operator == "setOVRC3" then setOVR(3, argument) - elseif operator == "set_OVR_C4" then + elseif operator == "setOVRC4" then setOVR(4, argument) - elseif operator == "set_OVR_C5" then + elseif operator == "setOVRC5" then setOVR(5, argument) + elseif operator == "clearOVR" then + clearOVR(argument) + end + else + local operator = tostring(args) + if operator == "clearAllOVR" then + clearAllOVR() end - end end end