How to Write Your First Rhino Script for a Mod
Understanding What Rhino Does
Rhino is a scripting engine that other mods use to run JavaScript. You do not write scripts for Rhino itself; you write scripts for a mod that has integrated Rhino support. Before writing anything, check the documentation of the mod you want to script for, since each mod exposes its own functions, events, and objects to the script environment.
Creating and Loading a Script
1. Locate the folder the host mod uses for scripts. This is usually inside the mod's config or data directory, and the mod's own documentation will name it.
2. Create a new file with a .js extension. The filename often matters because some mods load scripts by name or category.
3. Write plain JavaScript. You can declare variables, define functions, and use loops exactly as you would in any JS file.
4. Reference the host mod's API objects. These are injected into your script's scope by the mod, so you call them directly rather than importing them.
5. Save the file and reload scripts using whatever command or restart the host mod provides.
Testing Safely
Start with a trivial script that logs a message, so you can confirm the file is being loaded at all. Once you see output, gradually add API calls. Keep a backup of working scripts before experimenting, because a syntax error can prevent the whole script from loading.