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.
The Lua counterpart is just used for syntax highlighting and auto-completion purpose in the V-REP internal code editor.
C synopsis simInt simRegisterScriptVariable(const simChar* varNameAtPluginName,const simChar* varValue,int stackhandle)
C parameters
varNameAtPluginName: name of the variable, combined with the plugin name: variableName@pluginName. Avoid using too simple variable names, otherwise they might clash with other plugins. Also, always use the simXX. prefix (e.g. simMyPlugin.myCustomVariable) for the variable name. The plugin name should be the exact same name used while loading the plugin via simLoadModule (if the plugin name is v_repExtMyPlugin.dll, this should be MyPlugin).
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 (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 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. If a stack is provided, it will be released at a later point by V-REP.
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
number result=sim.registerScriptVariable(string varNameAtPluginName)
Lua parameters
varNameAtPluginName: name of the variable, combined with the plugin name: variableName@pluginName. Avoid using too simple variable names, otherwise they might clash with other plugins. Also, always use the simXX. prefix (e.g. simMyPlugin.myCustomVariable) for the variable name. The plugin name should be the exact same name used while loading the plugin via simLoadModule (if the plugin name is v_repExtMyPlugin.dll, this should be MyPlugin).
Lua return values
result: 1 if the variable was registered, 0 if the variable was replaced because it already existed, -1 in case of an error

All regular API functions on one page