Advanced - shadowfacts/ShadowJS GitHub Wiki
Loading Other Scripts
If you have a very large script it may be useful, for the purposes of code cleanliness and ease-of-maintenance. First, you'll want to split your code into a couple of files. For this example, the file will be main.js
and furnace.js
. After moving any code pertaining to furnaces to furance.js
, we can add a line of code to main.js
that tells ShadowJS to load furnace.js
.
ShadowJS.eval("furnace.js");
This tells ShadowJS to parse and run the file called furnace.js
. The path is automatically prefixed with config/shadowfacts/scripts/
, so there's no need to add that.
Directly Accessing Java Classes
Edit: This has been removed, only ShadowJS classes may be accessed from scripts now. This is to prevent scripts from doing malicious things.