Customization scripts

A customization script can be used to customize a simulation scene or model to a great extent: imagine a model that was dropped into a scene and that is able to configure or adapt itself, even when simulation is not running. This could be a robot where the user can adjust the various link lengths with a single slider repositioning.

Customization scripts are executed all the time (within a same scene): when simulation is running, as well as when simulation is not running. They follow a precise calling or execution order and can run threaded or non-threaded. Double-clicking their icon in the scene hierarchy opens the script editor.

A customization script is typically segmented into system callback functions, the most important ones are:

  • sysCall_init. This function is executed just one time, the first time the script is called. Usually you would put some initialization code in this part.
  • sysCall_thread. This function is the entrance to the script's threaded execution code. Threaded code is interrupted (and later resumed) on a regular basis by CoppeliaSim, by default. This behaviour can however be adjusted via sim.setStepping. See also the other thread-related API functions for more details.
  • sysCall_nonSimulation. This function is executed on a regular basis, when simulation is not running.
  • sysCall_beforeSimulation. This function is executed once just before simulation starts.
  • sysCall_afterSimulation. This function is executed once just after simulation ended.
  • sysCall_cleanup. This function is executed one time just before the script state is destroyed (e.g. when the script is removed)