1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2025-12-23 15:52:55 +01:00

Update scripting.md

This commit is contained in:
ZehMatt
2021-08-05 17:08:19 +03:00
parent f3f25ad8e0
commit dca117e5a0

View File

@@ -41,6 +41,7 @@ registerPlugin({
authors: ['Your Name'],
type: 'remote',
licence: 'MIT',
targetApiVersion: 34,
main: main
});
```
@@ -49,6 +50,12 @@ This will log a message to the terminal screen (`stdout`) when you open any park
The hot reload feature can be enabled by editing your `config.ini` file and setting `enable_hot_reloading` to `true` under `[plugin]`. When this is enabled, the game will auto-reload the script in real-time whenever you save your JavaScript file. This allows rapid development of plug-ins as you can write code and quickly preview your changes, such as closing and opening a specific custom window on startup. A demonstration of this can be found on YouTube: [OpenRCT2 plugin hot-reload demo](https://www.youtube.com/watch?v=jmjWzEhmDjk)
## Breaking changes
As of version 34 there are breaking Api changes.
> Version 34
```Entity.type will now return "guest" or "staff" instead of "peep"```
## Frequently Asked Questions
> Why was JavaScript chosen instead of LUA or Python.
@@ -73,6 +80,12 @@ Scripts can consist of any behaviour and have a large memory pool available to t
The APIs for OpenRCT2 try to mimic the internal data structures as close as possible but we can only add so many at a time. The best way to grow the plug-in system is to add APIs on-demand. So if you find an API is missing, please raise an issue for it on GitHub and also feel free to submit a pull request afterwards.
> What is ```targetApiVersion```
In case there are breaking Api changes plugins can use this to keep the old Api behavior, as an example in version 34 ```Entity.Type``` would no longer return "peep" for
guests and staff, instead it would return either "guest" or "staff", so if your plugin expects "peep" you can specify the version 33 to keep the old behavior. See the list
of breaking changes. If this is not specified it will default to version 33, it is recommended to specify the current api version.
> How do I debug my script?
Debugging has not yet been implemented, but is planned. In the meantime, you can use `console.log` to print useful information for diagnosing problems.