LUA Getuservar

  • Hi,


    how do i perform the grandMA3 version in LUA of the gma.user.getvar?


    Andreas, for grandMA2 you had a great topic about LUA tips and ticks, that helped me a lot. Will there be one for grandMA3 with the basic stuff to push us in the right direction?


    thanks a lot.

  • Sorry, I don't have anything to add at this point.


    Lua is in my opinion currently part of the internal workings of the console, and at the moment I neither have the knowledge nor the desire to push anyone in any directions.

  • I have no idea about getVar but string formatting can be done with Echo() (to the System Monitor), Printf() or, ErrPrintf(). They all use c-Style formatting. If you are looking for something like C's sprintf string.format is part of lua and works as expected.


    HOWEVER be very careful, it is very easy to get a crash if you mistakenly use the incorrect formatting specifiers


    Examples:

    Echo("%d, 0x%x, O%o, %f", 42, 42, 42, 42.1) -- (to SystemMonitor) 42, 0x2a, O52, 42.100000
    Printf("%d, 0x%x, O%o, %f", 42, 42, 42, 42.1) -- (to Cmd and SystemMonitor42, 0x2a, O52, 42.100000 (%f = 0 if input is int)
    ErrPrintf("%d, 0x%x, O%o, %f", 42, 42, 42, 42.1) -- (to Cmd and SystemMonitor42, 0x2a, O52, 42.100000 (%f = 0 if input is int)
    -- Printf("DON'T DO THIS %s", 1234) -- Passing a number to a string will cause a crash.


    x = string.format("Hello %d World", 42)
    Printf ("Formatted, %s", x)
    -- Formatted, Hello 42 World


    I have also found it very helpful reading through the plugins included on the desk, although you need to be very careful running them! If you are on PC/Mac you can navigate to the plugin path and search them all. Lots of very good information in there but it still seems a little early, lots might change, crashes may happen.


    As Andreas says I also don't want to lead you down the wrong path either since the included plugins are very low level and much could easily be removed from user-land access in the future. If you have a working knowledge of programming languages you can use them as a kind of documentation however - 1) nothing is really documented (thus I would assume not supported) B) There is no safety net, III) Your mileage may very.

  • nice extensive answer Hoss. i also checked the current plugins. A friend of my had a look in the desk and saw a lot of functions are not implemented in the api yet. Andreas had a nice topic in the past with some basic rules we could use, and also a few examples that worked really well.


    i hope the next update will come soon and fix a lot and make the lua features at least as workable as in the grandMA2 series, otherwise we cannot call this progress i guess. Let's wait and see for now then.

  • I do recall that post and it was very helpful indeed.


    I did a little Digging around today in _G and found a number of interesting functions. The errors that LUA responds with are really good, so often you can figure out what it the function needs to run properly. I found things like GetVar(), DelVar() and many more, but haven't had a chance to test them out if they are even wired up.



    My plugins are really just for my memory, and maybe they help someone along the way :)

  • sounds like you made some good progress. i hope MA will release some documentation soon about the features already build into the lua api. found stuff about _G also on the stockoverflow website. thanks for your support