Triggering a cue/macro at a specific time with LUA.

BECOME PART OF THE COMMUNITY - Sign up here
  • Hi,

    I am actually running my GMA3 system in GMA2 mode because I need the agenda feature.

    I heard that there is a way to mimic the Agenda function using LUA in my GMA3 show file.

    I am new programming LUA, so is there anyone that can help me with some hint for building that plugins, or with an example of a LUA code that could trigger a cue or a macro at a specific time?

    Thanks!

  • I've added a fair about of information on the plugin API, and some examples as well there are example plugins on the console. I personally haven't done any agenda type code, but it's definitely possible using os.time(), or perhaps something simulare in the LUA api.

    The only issue that comes to mind is I'm not sure how to automatically start your code unless you are onPC. Since there currently an auto start functionality you need some sort of action to start your plugin.

  • while a full unattended agenda plugin would require quite some work, in case you just need to give a command that it executed later at a given time, maybe a macro with this lua one-liner could be helpful:

    (example: 'Off Seq Thru' @ 10:30PM)

    Lua "local mytime, mycmd = '22:30','Off Seq Thru'; repeat Echo('waiting for %s to perform %s',mytime,mycmd); coroutine.yield(59) until os.date('%H:%M') == mytime; Echo('its time!'); Cmd(mycmd)"

  • The only thing to be very careful about using a loop like this is making sure it does not run more then once. If you end up calling this 3 times and the command is something like go sequence 1 then when the time happens you will end up going 3 times.

    Setting a variable and checking for it's existence at the start of the lua code would help.

  • "using a loop like this" was intentional from my side, to enable multiple timed command executions (at same or different times with same or different commands) using the same basic core code that fits inside a commandline embedded Lua-snippet.

    but yes, it is important to notice that my description "to give a command that it executed later at a given time" does mean that if you give the command several times, it would be executed later several times.

  • Just want to give you a follow up!

    After learning the basics of lua and have done several tests, I finally achieved my goal.

    I pretty much grab Andreas code and add a second function that runs only at the last minute with a much faster yield time, so I achieve to have around 1/100 of a second of precision.

    And to avoid my cmd to be executed several time, Instead of calling the plugin directly, when I need my sequence to run the next day, I call a 2 step macro that put the plugin to off before calling it:

    “Off plugin 1”

    “Call plugin 1”

    Here is my code I use in the plugin:

    local mytime = "09:29";

    local mytime2 = "09:30:00";

    local mycmd = "Go Seq 1"

    function Cue()

    repeat

    Echo('waiting for %s to perform %s',mytime2, mycmd);

    coroutine.yield(0.01) ;

    until os.date('%H:%M:%S') == mytime2;

    Echo('its time!');

    Cmd(mycmd);

    end

    function PreCue()

    repeat

    Echo('waiting for %s to perform function Cue',mytime);

    coroutine.yield(59)

    until os.date('%H:%M') == mytime;

    Cue();

    end

    return PreCue


    Thanks so much to both of you!!

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!