Regular API function

simRegisterScriptVariable

Description
Registers a script variable. Each time a script is run for the first time, registered variables will be set. Can also be used for more complex operations as in following example:
simRegisterScriptVariable("simUi","require('customUi')",0);
which is equivalent with an implicit simUi=require('customUi') command in the initialization phase of every script.
C synopsis simInt simRegisterScriptVariable(const simChar* varName,const simChar* varValue)
C parameters
varName: name of the variable
varValue: value of the variable. Can be NULL, in which case the value of the variable will be the top item of the provided stack.
stackHandle: a stack handle obtained with simCreateStack. Set to 0 if varValue is not NULL. Set to -1 if varValue is not NULL and you do not want the variable to appear in the script editor auto-completion list.
C return value
1 if the variable was registered, 0 if the variable was replaced because it already existed, -1 in case of an error
Lua synopsis -
Lua parameters
-
Lua return values
-

All regular API functions on one page