πŸ“– User Guide

This user Guide is updated regularly. It allows you to enter in the details to learn how to use the editor.

πŸ“„ View manual in PDF format

Listen in voice mode :

Scripts

Last update: January 07, 2026

πŸ”— Create a new script

Let’s start with the toolbar located above the script list: πŸ› οΈ



- The first icon allows you to create a JavaScript script. Behavior scripts use this language. πŸ’»
- The second icon allows you to create PHP scripts. This is useful for reading, writing, or saving text, JSON, HTML files, etc. We will cover this later. πŸ“„
- The third icon allows you to rename a script. Only rename your own scripts, not the default ones. ✏️
- The fourth icon allows you to delete a script. Do not delete existing default scripts, as they will be restored with every Realm-Crafting update. ❌
- The fifth icon allows you to save your script, whether it is JavaScript or PHP. πŸ’Ύ
- The sixth icon opens the behavior script manual, where you can discover the available functions along with their descriptions. πŸ“–

To begin, we will create a JavaScript script by clicking the first icon. By default, you will get something like this:

/*jshint esversion: 6 */	
/**  
 * @class className 
 * @description This behavior allows you to trigger an event when the object enters a specified zone.
 * @extends {Behaviors}
 */
class className extends Behaviors {
	static isZoneTrigger = true;
	constructor(object) {
        super(object);
		/*
		this.object = the object to which the behavior script is attached;
		*/
    }	
	/**
     * Initializes the className by adding configuration options (for editor).           
     */
	init() {	
		// Example:
		this.addConfig("alpha", "input", {
            label: "Transparency (0-1)",
            type: "number",
            min: 0,
            max: 1,
            step: 0.01,
            defaultValue: 0.5,
            id: "alpha",
            onChange: () => this.savePropertyValue("alpha")
        });		
	}
	/**
     * Initializes the className by adding configuration options (for game).           
     */
	start() {
		// Example:
		const alpha = this.getBehaviorProperty("alpha", 0.5);
		this.object.alpha = alpha;

		this.registerZoneTrigger("onEnterZone");
	}
	/**
     * Triggers the behavior when a specified event occurs by calling the executed method (for game). 
     */
	trigger(event) {
	 	if (event.type === "onEnterZone") {
			this.execute(); // Or any other method
		}
	}	
	/**
     * Executes the behavior (for game).     
     */
	execute() {
		// Use BabylonJS here
	}
}
 /**
 * Registers a behavior class with a given name.
 * @param {String} name: name of Behavior
 * @param {Function} function: behavior class
 */
BEHAVIOR.register("className", className);


As you can see, your script already contains the main functions by default, along with comments explaining their purpose. ✨
Here is what you should remember for now:

The first line of the script:
/*jshint esversion: 6 */

This line is mandatory for all scripts. It helps the code editor work correctly. βœ…

Next, the class declaration:
class className extends Behaviors

All behavior scripts extend the Behaviors class. It connects the script to objects, the editor, and the game, and provides ready-to-use features. πŸ’‘

The main functions:

constructor(object) : initialize your variables here. Do not call functions inside the constructor. πŸ—οΈ
init() : called only by the editor to add configurable properties. Use addConfig() to create interactive fields. βš™οΈ
Example of addConfig():
this.addConfig("rotationSpeed", "input", {
	type: "number",
	label: "Rotation speed",
	id: "rotationSpeed",
	defaultValue: 1.0,
	onChange: (value) => {
		this.savePropertyValue("rotationSpeed", value);
	}
});

start() : called when the game starts. It allows you to initialize variables or objects at load time. πŸš€
trigger(event) : called when an event occurs (for example: the player enters a zone). 🎯
execute() : executes the defined behavior (often called from trigger()). πŸ”„

BEHAVIOR.register("className", className); : registers the script using its name. 🏷️

πŸ’‘ Note: not all default functions are mandatory.
- If a script has no properties, init() can be removed.
- If the behavior can be fully handled in start(), then trigger() and execute() may be omitted.

The editor is flexible and does not force you into a single way of coding. You only need to understand the purpose of each function. πŸ”‘

We have now seen the basic structure of a script and the role of the main functions.
In the next chapter, we will look at how to fill these functions step by step. πŸš€


top  page