-
-
Notifications
You must be signed in to change notification settings - Fork 51
script api
For Advanced Users Only
ElementZero supports the scripting system.
For more information, and basic documentation, for the vanilla scripting API, click here.
In addition to behavior packs, scripts can also be added to a dedicated scripts
directory.
In order to enable scripting, you need to turn on experimental features. This can be done in custom.yaml
.
The entrypoint for dedicated scripts is scripts/index.js
. You can also put them in a behaviour pack.
Bedrock.dev currently has the best, most up to date documentation for the "vanilla" scripting.
A very useful feature which EZ adds is ESM (short for ES Modules)
This means you can use import
statements (see here.
From index.js
, you can import other scripts for their side effects only, so their code is ran.
An example of an index.js file could be:
import "./combat/index.js"
import "./info/index.js"
import "./mobReward.js"
console.log("Import finished");
Here, ./combat/index.js
could have even more import statements, so you can build up a folder structure. This is unnecessary, but can help make your scripts directory neater.
If a certain script requires it, you can also import functions from other EZ plugins.
Some plugins which add scripting support are: Economy, BossBarSupport and ChatAPI
You can use the import statement in the following way:
import {
whatToImport,
whatElseToImport
} from "ez:modulename";
You can also import and export declarations from your own scripts. In this case, you would replace "ez:moduleName"
with "./fileName.js"
.
Logs a message to the console. message
is any string you like.
Executes a command. command
is a string containing the command you wish to execute. Note: do not start the string with /
.
A. Installation:
- Windows
- GNU/Linux (Using Docker and Wine) (Recommended)
- GNU/Linux (Wine without docker) (Not Recommended)
B. Installing and using the translation resource pack (Otherwise the command help menus and responses will be gibberish)
For Advanced Users Only