Editor Scripting is a feature that can be accessed in command line by entering EditorScript keyword.

*Practical and potential uses to be determined

Getting Started

Editor script uses JS (JavaScript), also not to be confused with Java which is a object oriented programming, JS is a lightweight programming language, this should mean that it's pretty easy to learn.

Anyways, were here to learn about the basic concepts of JS and compare it to fancade scripting for better understanding. Lets start with variables!

Variables

Unlike most programming languages JS uses a versatile variable declaration this means you can set a variable to any type value casually. JS uses 3 variable declaration key:

var - commonly used variable, is global and can be called anywhere after declaration

const - is a variable that represents a constant value, usually declared before everything

let - is a variable that represents a local variable, its value only persist inside the codeblock {} where it is located

Each of this key can represent either num value types (int, float), tru types (bool), or String and can be changed anytime according to the value type it holds. Additionally it can also declare arrays, objects and functions.

Arrays and Objects

• An array basically acts as a list that is automatically indexed, you can declare an array like this

var list = ["apple", "orange", true, 100];

var list = [];
list[0] = "mango";
list[2] = [0.1, 1];
//outputs ["mango",, [0.1, 1]]

• In the other hand object is an "list of properties" to represent an "object", it works similarly to array but the properties are defined by a name as if it's a variable, you can declare an object like this:

var obj = {
    name: "grass",
    color: [0, 255, 0],
    wilted: false,
    leaf: {
        type: "pointy",
        count: 4
    }
}

var obj = {};
obj.something = "something";
//outputs {something: "something"}