Script editor

The script editor allows editing simulation- and customization scripts in CoppeliaSim. It is opened by double-clicking a script object 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 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 automatically applies the changes to a simulation script. The user can also explicitly 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 following:

    #python include myExternalPythonFile --lua require('myExternalLuaFile')

    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.

    You can also set an external script editor by editing usrset.txt and restarting CoppeliaSim: a double-click on the script object now opens the script in the specified external editor.