Regular API function

simCallScriptFunctionEx
remote API equivalent: simxCallScriptFunction
RosPlugin API equivalent: simRosCallScriptFunction

Description Calls a script function (from a plugin, the main client application, or from another script). This represents a callback inside of a script. 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 call non-threaded child scripts.
When calling simulation scripts, then simulation must be running. See also simSetScriptVariable.

Data exchange between a plugin and a script happens via a stack. Reading and writing arguments from/to the stack gives you a maximum of flexibility, and you wil be able to exchange also complex data structures. But it can also be tedious, if your data structures are anyway relatively simple. In that case you can use the helper classes CScriptFunctionData and CScriptFunctionDataItem located in programming/common and programming/include: they will greatly simplify the task.

Use following 4 functions in the helper class: pushOutData_scriptFunctionCall, writeDataToStack_scriptFunctionCall, readDataFromStack_scriptFunctionCall, and getOutDataPtr_scriptFunctionCall.
C synopsis simInt simCallScriptFunctionEx(simInt scriptHandleOrType,const simChar* functionNameAtScriptName,simInt stackId)
C parameters
scriptHandleOrType: the handle of the script, otherwise the type of the script:
sim_scripttype_mainscript (0): the main script will be called.
sim_scripttype_childscript (1): a child script will be called. In that case, functionNameAtScriptName should also contain the name of the object associated with the script.
sim_scripttype_jointctrlcallback (4): a joint control callback script will be called. In that case, functionNameAtScriptName should also contain the name of the object associated with the script.
sim_scripttype_contactcallback (5): the contact callback script will be called.
sim_scripttype_customizationscript (6): a customization script will be called. In that case, functionNameAtScriptName should also contain the name of the object associated with the script.
sim_scripttype_generalcallback (7): the general callback script will be called.
functionNameAtScriptName: the name of the Lua function to call in the specified script. If scriptHandleOrType is sim_scripttype_childscript, sim_scripttype_jointctrlcallback or sim_scripttype_customizationscript, then functionNameAtScriptName should also contain the name of the object associated with the script: "functionName@objectName".
stackId: a stack handle. The stack represents the function's in/out values. See also the available stack functions.
C return value
-1 in case of an error
Lua synopsis ...=simCallScriptFunction(string functionNameAtScriptName,number scriptHandleOrType,...)
Lua parameters
functionNameAtScriptName: a string representing the function name and script name, e.g. myFunctionName@theScriptName. When the script is not associated with an object, then just specify the function name.
scriptHandleOrType: the handle of the script, otherwise the type of the script:
sim_scripttype_mainscript (0): the main script will be called.
sim_scripttype_childscript (1): a child script will be called.
sim_scripttype_jointctrlcallback (4): a joint control callback script will be called.
sim_scripttype_contactcallback (5): the contact callback script will be called.
sim_scripttype_customizationscript (6): a customization script will be called.
sim_scripttype_generalcallback (7): the general callback script will be called.
...: any number of arguments that will be handed over to the called function.
Lua return values
...: any number of return values from the called function.

All regular API functions on one page