Set Value in Object direcly from lua without the CMD

BECOME PART OF THE COMMUNITY - Sign up here
  • Hi to everyone, i almost saw all the thread here , and in the manual but i can't find an answer.

    It's possible "Set" the propiety of the objects without use the funtion CMD ?

    For example if i want make an pluging that create some macro and put the commands inside the row, can i do without use the funtion CMD?

    The wall im in front it's when i need to write inside a macro a Command that have also the "",

    Also the operation of Store, there is a funtion in LUA to use without use the CMD?

  • In the MA3 command line you can use single quote inside double quotes, and vise versa.

    • "This 'is' okay"
    • 'This "is also" okay"
    • "This "is" not"
    • 'Nor 'is' this'

    Hi Ryan what a pleasure read you, i already so this your post and ok.

    But if i have to put in a macro line the sintax sendOSC 1 "/go,s,1" where the 1 it's a variable i didn't find a solution.

    So the normal sintax from the command line :
    set macro 11.1 Property "COMMAND" "sendOSC 1 '/go,s,1'"
    And this works perfectly

    then in LUA 

    Cmd("Set macro " ..SG_Num..".1" "Property 'COMMAND' 'sendOSC 1 '/go,s,1'")
    Already here I have some problems to do it correcly

    And if the last num it's a variable from the lua i did't find a way

  • Hi,

    Here below is an example that shows how to use Set, Create and Insert functions as well as using double quotations.

  • Hi,

    Here below is an example that shows how to use Set, Create and Insert functions as well as using double quotations.

    Ehi Luke , that it's amazing , it's the code i need it.

    But one question, where di you get the information to create this code?? i look almost everywhere since 3 days before ask a help here.

    Anyway thank you so much

  • When you type HelpLua in the command line, it will export all the gMA3 Lua Functions into a text file in your gma3_library folder.

    You can find it’s location in the System Monitor after you type the command.

    It’s a kind of API documentation and might take while to wrap your head around the syntax conventions.

    The best way to understand it would be to look at the descriptions of the functions that you already know :)

  • When you type HelpLua in the command line, it will export all the gMA3 Lua Functions into a text file in your gma3_library folder.

    You can find it’s location in the System Monitor after you type the command.

    It’s a kind of API documentation and might take while to wrap your head around the syntax conventions.

    The best way to understand it would be to look at the descriptions of the functions that you already know :)

    Great , I always look to that file and also to the manual, so now i looking to read somewhere how to find how your logic of those command.

    Everything is base on the Function ROOT()

    In the file there is this : Root(nothing): light_userdata:handle

    In the manual the "Handle" for lua :

    Many functions require a handle as an argument or return a handle.

    The handle is a custom data type called "light_userdata".

    The handle is a unique identifier that refers to a grandMA3 object, for instance, a specific sequence, cue, preset, or fixture.

    From the doc, i understand at least Root(): ShowData.DataPools.Default.Macros due it's write like that I can't see the single dot in the API.
    but we can think it's a rule from Lua language and it's always like this. ok this.

    So correct me to how exactly read this and be independent

    Set(light_userdata:handle, string:property_name, string:property_value[,Enums.ChangeLevel:override change level]): nothing
    Root(nothing): light_userdata:handle

    Code
    Root().ShowData.DataPools.Default.Macros [1] : Set ( "Name", "Hello" )
    
    --the funtion "Root()" follow by the root that I need, then in the [] the number --from the API where i get this Need --i mean the []? 
    --then :  -- are the light_userdata or the handles of the funtion Root()?

    then Set ( "here the first one it's the string of the property name? in the api the first it's light_userdata" , "the string of the value that i want.")

    The only thing i can't see it's why there are the \\ in the

    Code
    MacroObject[ MacroNumber ][ 1 ]:Set( "Command", "Label Sequence 1 \"Hello World\"" )

    It's a base syntax for lua? i cant see the sense of the \" here the string \" or to put another quote inside the lua you need to put the slash before?

    Thankyou for all the information.

  • Hi Thank you all for the great information,

    How i can put in the funtion SET also the ()

    Code
    MacroObject[tonumber(SG_MACRO_NUM)][1]:Set("Command", "SetUserVar SG_FADE (\"SET FADE FADER\"))

    I didn't find it in the page you link.

    The () are normal signs inside a string, so they do not need any special action. In your code however you miss the closing quotes at the end.

    Code
    MacroObject[tonumber(SG_MACRO_NUM)][1]:Set("Command", "SetUserVar SG_FADE (\"SET FADE FADER\")")

    I colored the blocks in an attempt to show the scope of each of them. If you use Visual Studio Code to write lua, there are many extensions that automatically color the brackets and cuotes so you have a better overview.

    Beware that () do have a special meaning in search strings used in for example the string.match function. In these functions Lua uses another set of escape characters. In this case you'll need to use %( or %) to indicate literal brackets. More information you can find here: https://www.lua.org/pil/20.2.html

  • Hi Thank you all for the great information,

    How i can put in the funtion SET also the ()

    Code
    MacroObject[tonumber(SG_MACRO_NUM)][1]:Set("Command", "SetUserVar SG_FADE (\"SET FADE FADER\"))

    I didn't find it in the page you link.

    sorry, I did not see your last line from your comment.
    the link works fine to me (from Spain), but if you just Google "lua backslash" you´ll surely find the informantion you need.

  • Lua has many ways to achieve the same:

    below are 4 ways to set the command text of the first macroline of macro 1 of the current datapool :

    local Macropool = DataPool().Macros

    local myMacro = Macropool[1]

    local myMacroline = myMacro[1]

    --Alternative 1, calling the Set function from the global Obj table :
    Obj.Set(myMacroline, 'Command', 'Fixture Thru')

    --Alternative 2, calling the same Set function via the actual object :
    myMacroline.Set(myMacroline, 'Command', 'Fixture Thru')

    --Alternative 3, calling the same Set function as a method, using colon instead of dot, effectively passing itself as the first argument :

    myMacroline:Set('Command', 'Fixture Thru')

    --Alternative 4, invoking the same Set function via the object's metamethod:

    myMacroline.Command = 'Fixture Thru'

    if you try to replace Command with e.g. Comand, you will see that all four alternatives report error by the same Obj.Set function

    the HelpLua output describes the core functionality of alternative 1/2, however common usage is often alternative 3 or 4, which may be confusing if you don't know that they are the same.

  • Hi,

    Here below is an example that shows how to use Set, Create and Insert functions as well as using double quotations.

    Hi Luke your help it's been really great.

    I wish to go a little head, and probably I have some gap of knowledge so sorry if it's a silly question,

    It's possible work also with range? like the

    Code
    MacroObject:Create( MacroNumber ) -- but not do it for one number but say already create from 1 to 50 ?

Participate now!

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