• Hi Hive Mind,


    I can see in the _G of the LUA API that there are some commands called, Getvar, Delvar and Setvar.


    What is the syntax to set / use these commands?

    i thought it could be Setvar("variable", value) but that doesn't work.


    thanks a lot for the help.

  • These functions requires you to pass a pointer to the variable collection in question, as first argument.


    e.g current user

    SetVar(UserVars(),'model','T-1000')

    e.g. userprofile "Default"

    SetVar(ShowData().UserProfiles['Default'].Variables, 'manufacturer','Cyberdyne')

    e.g. globalvars

    SetVar(GlobalVars(),'mission','World domination')



    remember that Lua is case sensitive, your example Setvar would not work no matter what arguments you try to pass.

  • Hi,


    thanks for your super answer Andreas, it helped me a lot making some steps.


    i was just wondering because of your answer if it is possible to use our local lua variables to set the global or user variables in the desk. I can't seem to escape the , (comma) that is in the Setvar command.


    example: string.format("SetVar(GlobalVars(),'%s','%s'", var1, var2)


    and var1 and var2 would be created in a table or array or other way inside the LUA plugin.


    thank you for your help so far.

  • Not sure I understand what you are trying to do, but maybe the plugin example below can get you going..


    return function()


    local mytable = {question = 'Not sure', answer = 42}

    local vars = GlobalVars()


    for key,value in pairs(mytable) do

    SetVar(vars, key, value)

    end


    Cmd('GetGlobalVar *')


    end