-
Notifications
You must be signed in to change notification settings - Fork 0
Creating a Script
There are 3 requirements for Scripter to be able to see script-files:
- They have to be located in /config/Scripter, or a subdirectory therein
- They have to contain the word
scripterin their file-name - They have to have the extension
.js
File-names need to contain scripter as this allows one to create other JS scripts in the same folder, that will not be read by Scripter. This allows one to have a central file that houses commonly used functions across several scripts etc.
The very first line has to be a comment. This comment is read by Scripter as it maps what scripts to call during a specific event.
If one uses the comment //PlayerInteractEvent.RightClickBlock on the first line, then Scripter will execute this script when this event is called.
For a full list of events one can use, please read [events].
There is one further limitation on scripts. Scripter will only call one function from each script-file, and this function has to be named onEvent and it has to have a single parameter, for example: var onEvent = function(event){}
This function can be seen as a miniature main method, for this script. You can call other functions from this, and they will be executed during the specified event.