Your First Script

To create your first script in MCJS, follow these steps:

  1. Create a file with the ".js" extension in the "scripts" folder located at the plugin directory.

  2. Open the ".js" file in your preferred code editor.

  3. Use the following syntax to write your script:

function build(build) {
    // Your code here
}
  1. Save the file with the ".js" extension in the "scripts" folder of the plugin.

Once you have created and saved your script in the "scripts" folder, you can run it using the /mcjs reload command on the server.

Basic Syntax

In MCJS, scripts are written in ECMA Script 5, and the syntax is similar to standard JavaScript. The script begins with a function called "build," which will run when the script is initiated. This function takes a parameter that is an object of type "ScriptBuild", which provides methods for initializing the plugin and customizing its behavior.

function build(build) {
    // Use the "ScriptAPI" object via the reserved word "API".
    API.broadcast("Hello World!");
} 

Last updated