A simple explanation on how to use scripting in Iris. You find & create scripts in the 'scripts' folder.
You will need to understand a bit about Plugins & Java before diving head first into this. While it is JavaScript, it's really just a scripting medium to access & modify Java code / variables.
You can define scripts in your project under the scripts folder. Scripts have a .js file extension and are written in JavaScript.
You can then run this script with /iris studio execute <script>
Any Iris data type (except scripts & objects) can have preprocessors added to them. Take this biome for example
Notice that we have added the preprocessor name-prefixer.js
. This script will be called when this json file is loaded into an IrisBiome class. You can then change properties about this biome object right before it's actually used by the generator. Let's prefix it with the dimension name!
We are using Rhino by Mozilla to run JS. Because of this, you are capable of actually running anything that exists on the JVM (mc server). For example, you could use the Bukkit API just like any plugin would... send a message to every player?
The Iris api is given to you via the namespace Iris. However it's actually pointing to the IrisScriptingAPI class. Take a look at that class, and you will see it has methods in it to access parts of Iris specifically.
Avoid accessing fields in the IrisScriptingAPI class, Instead of using Iris.location, use Iris.getLocation().