Regular API function

simSetScriptVariable / sim.setScriptVariable

Description Sets or clears a script variable. The target script must be initialized for this call to succeed, e.g. when calling simulation scripts, then simulation must be running. See also sim.callScriptFunction.
C synopsis simInt simSetScriptVariable(simInt scriptHandleOrType,const simChar* variableNameAtScriptName,simInt stackHandle)
C parameters
scriptHandleOrType: the handle of the script, otherwise the type of the script:
sim_scripttype_mainscript (0): the main script is the target.
sim_scripttype_childscript (1): a child script is the target. In that case, arrayNameAtScriptName should also contain the name of the object associated with the script.
sim_scripttype_customizationscript (6): a customization script is the target. In that case, arrayNameAtScriptName should also contain the name of the object associated with the script.
sim.scripttype_sandboxscript (8): the sandbox script is the target.
sim.scripttype_addonscript (2): an add-on script is the target (the add-on needs to be running). In that case,arrayNameAtScriptNameshould also contain the name of the script (e.g. for add-on simAddOnB0RemoteApiServer.lua, B0RemoteApiServer is the script name)
variableNameAtScriptName: the name of the variable. If scriptHandleOrType is sim_scripttype_childscript, or sim_scripttype_customizationscript, then variableNameAtScriptName should also contain the name of the object associated with the script: "variableName@scriptName".
stackHandle: the handle of a stack object. The top stack item represents the variable value. If the handle is 0, then the variable will be assigned the value nil. See also the available stack functions.
C return value
-1 in case of an error
Lua synopsis sim.setScriptVariable(string variableNameAtScriptName,int scriptHandleOrType,variable)
Lua parameters
Similar to the C-function counterpart, with the difference that a stack object is not required, and the desired variable value can directly be appended to the first two arguments.
Lua return values
none