Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Basic support for plugin scripts. #2840

Merged
merged 5 commits into from
Jan 13, 2022

Conversation

ohlidalp
Copy link
Member

@ohlidalp ohlidalp commented Jan 5, 2022

This feature branch gives you the ability to run AngelScript scripts on launch and have them running continuously until the game shutdown, in both menu and simulation (both single and multiplayer).
The game interface is the same which terrain scripts use, with new extension: global object input which lets you retrieve configured controls and current input states.

There is an example script 'demo_script.as' in the "resources/scripts" directory (or 'resources/scripts.zip' package when installed). You can run it by 2 ways:

  • from command line: ror -runscript demo_script.as (you can load multiple scripts by using -runscript repeatedly)
  • from RoR.cfg: app_custom_scripts=demo_script.as (you can enter multiple filenames delimited by comma).

Showcase of the example script:
image
image
image

This is probably the least-nonsense feature I coded so far.

Copy link
Collaborator

@tritonas00 tritonas00 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice! You may want to add the new -runscript option in -help also

I used the existing scripting subsystem, just added config/commandline options to load scripts and made them update in main menu, too.
I also created an example/documentation script 'demo_script.as', find it in resources/scripts.
To see it in action, run with commandline '-runscript demo_script.as'.
Scripts are loaded from resources/scripts or ROR_HOME/scripts.

Changes:
added config cvar 'app_custom_scripts' - a comma delimited list of script names
added command line argument '-runscript <scriptname>' which can be used multiple times, and underlying cvar 'cli_custom_scripts'

Status:
the demo script runs OK while in main menu, but stops as soon as terrain is loaded.
Until now, ScriptEngine could really accomodate just a single terrain script - all properties and callback handles were stored directly as ScriptEngine member variables.
This commit factores these out to class ScriptUnit and adds enum ScriptCategory so everything can be organized well.
Also, TerrainManager now cleans up it's scripts.

Status: the demo script runs flawlessly both in menu, in terrain and back in menu. However, terrain scripting is broken - races don't load etc...
Terrain scripts work as usual and custom scripts work OK, too.
See 'resources/scripts/demo_script.as' for usage instructions.
…utEvents'.

Enum inputEvents contains all values of enum `events` in InputEngine.h.
Object InputEngineClass contains only a few important functions of InputEngine, see InputEngineAngelscript.cpp for listing.
InputEngine.h: just formatted the enum comments, no code change.

Demo script extended to showcase new abilities.
Added doxygen doc.
@ohlidalp
Copy link
Member Author

@tritonas00 Very nice! You may want to add the new -runscript option in -help also

Good idea, done.

@ohlidalp ohlidalp merged commit aab14d9 into RigsOfRods:master Jan 13, 2022
@ohlidalp ohlidalp deleted the AngelScript_custom branch January 13, 2022 11:46
@ohlidalp ohlidalp mentioned this pull request Jan 13, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants