Skip to content

Instantly share code, notes, and snippets.

@gnarfel
Created April 24, 2022 05:41
Show Gist options
  • Save gnarfel/d7b3f04b0f189f241ecec3f8fba7d517 to your computer and use it in GitHub Desktop.
Save gnarfel/d7b3f04b0f189f241ecec3f8fba7d517 to your computer and use it in GitHub Desktop.
return function()
local sm = 'sm 2.2' -- CLI 'SpecialMaster 2.2' or Prog Time
--Because of the archaic handle-based way MA2 works, these local variables
-- make the following script a LOT cleaner. They are simply short aliases
-- for the full LUA tables. -AF
local cmd = gma.cmd
local get = gma.show.getobj
local prop = gma.show.property
--This function returns the x.x version of the Program Time
function getlevel()
local handle = get.handle(sm)
if handle == nil then return 0 end
return tonumber(string.match(prop.get(handle, 'value'), "%d+.%d+"))
end
--This variable stores a 'cached' version of the level so we have
-- something to refer to if we ask 'is the new level different than
-- the old level?'
local oldlevel = -1
--repeat forever
while true do
--get a local version of the Prog Time (which needs to be divided
-- by 10 to be usable as a x.x value)
local level = getlevel()/10
--this is where we check to see if the cached value is different
-- than the current value. If the new value is different, we
-- need to updated the $PROGTIME show variable. This could also
-- be made a user variable, which would ideally make the MA2 not
-- freak out when you drag the fader in a multi console session.
--
--This is also where we update the oldlevel global variable to
-- the current state.
if level ~= oldlevel then
gma.feedback("New Prog Time level: " .. level)
gma.show.setvar("PROGTIME",level)
--If you wanted to run a macro each time you wiggle the fader
-- you can do it here. But I recommend not doing that.
--gma.cmd('macro "Update Wipe Speed"')
oldlevel = level
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment