Regular API function

simSetScriptVariable

Description Sets or clears a script variable (i.e. a Lua variable). Call this only:
a) from the main thread, or:
b) from a thread that originated from a threaded child script. In that case, you cannot set a variable in a non-threaded child script.
See also simCallScriptFunction.
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_jointctrlcallback (4): a joint control callback script is the target. In that case, arrayNameAtScriptName should also contain the name of the object associated with the script.
sim_scripttype_contactcallback (5): the contact callback script is the target.
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_generalcallback (7): the general callback script is the target.
variableNameAtScriptName: the name of the variable. If scriptHandleOrType is sim_scripttype_childscript, sim_scripttype_jointctrlcallback 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 number result=simSetScriptVariable(string variableNameAtScriptName,number scriptHandleOrType,variable)
Lua parameters
Similar to the C-function, 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
Same as C-function

All regular API functions on one page