Read property

  • Is it possible to read a property and put it in a variable?

    E.g. SetUserVar "Name" The name of Macro 1

    Also, is there any way to target 'this macro' as in the one that is running?

    E.g. SetUserVar "Name" The name of the macro that contains this line

    While I have your attention, what's the difference between "Go Macro X" and "Call Macro X"

    Go doesn't execute all the lines when I use it in another macro.

  • There probably is an easier way to do this but this simi-long form LUA one liner grabs the name of Macro Index 1 in DataPool 1 and stores it in a UserVar named Name.

    lua'local n,dp,i="Name",1,1;local m=Root().ShowData.DataPools:Children()[dp].Macros:Children()[i].name; SetVar(UserVars(), n, m)'

    I haven't played with trying to figure out what macro is currently running but you could cheat and set a user var first then use get that user var in the LUA, but again I'm sure there is a much simpler way do accomplish this, perhaps as a pure Macro.

    As for the difference between Call and Go+ I'm not sure for Macros. Looking at the MA2 Manual Call engages the object. but to me it seems like they do the same thing.

    Out of curiosity, what part of the macro is not running when you Go+ it.

  • Thanks hoss

    I was expecting the answer 'Yes, use command ReadProperty' or 'No'

    I tend to forget about Lua...of course it is possible :)

    A small code like that gives me something to experiment with too. Much appreciated.

    Seems to me only the first line is executed with Go+

    Note that this only happens when I start Macro X from Macro Y.

    E.g. I needed autosave because of all the crashes and made this:

    Macro 1:

    Save the show, wait 3 minutes

    Macro 2

    Macro 2:

    Save the show, wait 3 minutes

    Macro 1

    This did not work until I used CALL

  • yeah lua is really helpful. for example this one liner saves once every 5 minutes:

    lua"while true do coroutine.yield(5*60) Cmd('SaveShow') end"

    However it alone has a major issue in that once run it can't be stopped and 2) if you run it again you will get a second instance running (saving twice every 5 minutes).

    The way round this is to change out the while true to something you can change, for example:

    lua'local E,C,r,t = Echo,Cmd,1,3*60; E("Starting AutoSave"); while r == 1 do r = GetVar(UserVars(),"AutoSaveRun"); C("SaveShow"); coroutine.yield(t); end E("Exiting AutoSave");'

    This time when you run the command it will save once, wait 3*60 seconds then exit. To make it keep going run the command SetUserVar AutoSaveRun 1 before running the lua.

    Top stop it (and all other instances) it just run SetUserVar AutoSaveRun 0 Then the loop will eventually fall out and you should see "Exiting AutoSave" in the System Monitor.

    I could clean this up and make it only allow a single instance, but... more code, I'll add this to my list of plugins sometime though.