Login

Fancade Wiki

Updated Introduction to Editor Scripting.md (markdown)

... ...
@@ -4,7 +4,7 @@ Editor Scripting is an experimental feature that can be used to build levels by
4 4
Let's create a new level and enter the `EditorScript` command. You will be greeted by a simple code editor with some examples in place. The code might seem unfamiliar at first, because it is written in JavaScript. But don't be scared, because we will learn the basics in this tutorial!
5 5
6 6
## Functions
7
### Set Block
7
#### Set Block
8 8
So let's look at our first example.
9 9
```js
10 10
// Set block at position (x, y, z) in level or open block
... ...
@@ -20,7 +20,7 @@ setBlock(0, 0, 0, 3);
20 20
```
21 21
Copy this code and paste it in the editor, then hit `Run` and `Save and Close`. As you might have guessed, this puts a block on the coordinates `(0, 0, 0)`. The fourth value is the unique identifier for the Grass block to be placed. There is a list of unique ids for each built-in block, but what if we want to place a custom block instead?
22 22
23
### Find Block
23
#### Find Block
24 24
[Create a custom block](/wiki/build/how-do-i-make-my-own-custom-blocks), for instance `My Block`. Then replace your previous code with this one:
25 25
```js
26 26
// Find the block called "My Block"
... ...
@@ -74,7 +74,7 @@ for (let element of myBlocks) {
74 74
75 75
Objects `{}` works almost similarly to arrays but unlike it is not considered a collection of value but instead a single value composed of other values called "properties" and functions called "methods". Lets take for example a ball, you will ask, how bouncy is this ball? what is its radius? just like this ball an object has its own properties to determine its characteristics. Using it lets try to make a simple structure.
76 76
77
### Properties
77
#### Properties
78 78
```js
79 79
let justATree = {
80 80
x: 0,
... ...
@@ -92,7 +92,7 @@ justATree.position = [0, 0, 0];
92 92
```
93 93
properties are values that represent chracteristics of an object it can be any value type or a function. As you can see in our example we made the object `justATree`which contains properties named `x`, `y`, `z` and `component`. Using this properties lets try to make a method that will build the tree!
94 94
95
### Methods
95
#### Methods
96 96
methods are special properties of an object that can be used as instruction for its behaviors. Now lets try to add a new method named `build` inside `justATree`.
97 97
98 98
```js
Fancade Wiki