Regular API function

simRegisterScriptVariable

Description
Registers a script variable. 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/C++
synopsis
int simRegisterScriptVariable(const char* varNameAtPluginName,const char* varValue,int stackhandle)
C/C++
parameters
varNameAtPluginName: name of the variable, combined with the plugin name: variableName@pluginName
varValue: value of the variable. Can be nullptr, in which case the value of the variable will be the top item of the provided stack (or, if stackHandle is 0, varName will only be used for code auto-completion purpose).
stackHandle: a stack handle obtained with simCreateStack. Set to 0 if varValue is not nullptr. Set to -1 if varValue is not nullptr and you do not want the variable to appear in the script editor auto-completion list. If a stack is provided, it will be released at a later point by CoppeliaSim.
C/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
int result=sim.registerScriptVariable(string varName)
Lua
parameters
varName: name of the variable. The Lua version of this function will only be used for syntax highlighting and auto-completion purpose in the CoppeliaSim code editor
Lua
return values
result: 1 if the variable was registered, 0 if the variable was replaced because it already existed
Python
synopsis