Script editor

The script editor allows editing the various scripts in CoppeliaSim. It is opened by double-clicking a script in the script dialog, or by double-clicking a script icon in the scene hierarchy.

[Script editor]

The script editor has following features that make the code edition easier:

  • auto-completion
  • call tips
  • syntax highlighting
  • Highlighting of all occurrences of the selected word
  • source folding/unfolding
  • search and replace function
  • no need for explicit saving
  • jump to specific function
  • undo/redo
  • inspection/edition of included files
  • open of the documentation for the API function/constant under the mouse pointer, via the context menu
  • The API functions can easily be accessed by typing the first 3 letters (usually sim). When a script was modified, there is no need to explicitly save the changes: closing the script editor, saving the scene or starting a simulation will automatically apply the changes to the script. When a simulation is running, modifications to a given script will only take effect once a new simulation run is started. The user can also explicitely restart/reset a given script, for changes to take immediately effect.

    If you have recurring functions you wish to access from a given script, or if you simply wish to run code from an external file, you can do this with following for a Lua script:

    require "myExternalLuaFile"

    and for a Python script:


    In that case, make sure the file is named myExternalLuaFile.lua or, and do not forget to distribute it together with your scene or model, since that code will not be part of a CoppeliaSim file anymore. Searched path are usually following:

  • <CoppeliaSim executable>/
  • <CoppeliaSim executable>/lua/
  • <CoppeliaSim executable>/python/
  • <current scene path>/
  • <additional search path>/ (this path can be specified with variable additionalLuaPath in file system/usrset.txt)
  • Files included via the require directive can be opened in the same script editor by opening the popup menu over the file name.