We have a decently-capable scripting environment, and it will get expanded in a close future. This thread should be a catch-all introductory spot.
Credit is due: the scripting subsystem, along with a race manager script, was developed by former member 'neorej16' in circa 2010 - correct me if I'm wrong.
What's the programming language?
AngelScript http://www.angelcode.com/angelscript/ is a high-performance scripting library written with games in mind. The author provides support at GameDev forums: https://www.gamedev.net/forums/forum/34-angelcode/.
The language itself resembles C++/C#/Java, source files have extension ".as". The official documentation is exellently written: http://www.angelcode.com/angelscript/sdk/docs/manual/index.html
What can scripts do?
Online docs:
Either by including it with terrain or invoking by hand:
Ask right in this thread!
Credit is due: the scripting subsystem, along with a race manager script, was developed by former member 'neorej16' in circa 2010 - correct me if I'm wrong.
What's the programming language?
AngelScript http://www.angelcode.com/angelscript/ is a high-performance scripting library written with games in mind. The author provides support at GameDev forums: https://www.gamedev.net/forums/forum/34-angelcode/.
The language itself resembles C++/C#/Java, source files have extension ".as". The official documentation is exellently written: http://www.angelcode.com/angelscript/sdk/docs/manual/index.html
What can scripts do?
- [since 2022.04] Run everywhere: main menu, singleplayer, multiplayer.
- [since 2022.04] Draw arbitrary GUI using DearIMGUI, the same system used for game UI. https://github.com/RigsOfRods/rigs-of-rods/pull/2786
- [since 2022.04] Read console variables (RoR.cfg settings). https://github.com/RigsOfRods/rigs-of-rods/pull/2788
- Receive gameplay events https://ror-source-docs.netlify.app...2_game.html#a366408518753189dc7895f392b6ce8e6
- Receive eventbox hits (event boxes are defined in ODEF fileformat).
- Observe and modify game state: https://ror-source-docs.netlify.app/dc/d63/class_script2_game_1_1_game_script_class.html
- [dev build only] Configure/Start/Stop vehicle AI
Online docs:
- Detailed reference guide generated by doxygen: https://ror-source-docs.netlify.app/d2/d42/group___script_side_a_p_is.html - mind that we intentionally document both the codebase and scripting interface in single doxygen book.
- Plugin scripts: https://github.com/RigsOfRods/rigs-of-rods/pull/2840. An example plugin script with commentary: https://github.com/RigsOfRods/rigs-of-rods/blob/master/resources/scripts/demo_script.as
- Race creation guide: https://docs.rigsofrods.org/terrain-creation/race-generator/
- Some outdated intro to terrain event boxes: https://docs.rigsofrods.org/terrain-creation/scripting/
- Examples runnable in ingame console: https://github.com/RigsOfRods/rigs-of-rods/pull/2780
Either by including it with terrain or invoking by hand:
- By including the ".as" file(s) with terrain - see terrn2 fileformat, section '[Scripts]': https://docs.rigsofrods.org/terrain-creation/terrn2-subsystem/. This is the classic old method, used for i.e. races and event boxes. Note that if no script is provided, a bundled "default.as" is invoked. It provides the basic handling for spawners, garages and races.
- By placing the ".as" file(s) in 'Documents\My Games\Rigs of Rods\Scripts' and:
- [since 2022.04] running the game with command line parameter '-runscript <filename>'. You can use this command multiple times at once.
- [since 2022.04] setting 'app_custom_scripts' in RoR.cfg to a comma-separated list of filenames. Spaces in filename are acceptable.
- [dev build only] in game, opening console (tilde key) and using command `loadscript <filename>`.
- Scripts log to it's own logfile, 'Documents\My Games\Rigs of Rods\Logs\Angelscript.log'
- [dev build only] you can view and stop scripts using ingame console, top menubar, "Script Monitor" panel. https://github.com/RigsOfRods/rigs-of-rods/pull/2931
Ask right in this thread!
Last edited: