Updated Introduction to Editor Scripting.md (markdown)
commited
commit
998585512af369337b94dccc516169afd8b607c0
... | ... | @@ -1,11 +1,19 @@ |
1 | Editor Scripting is a feature that can be accessed in command line by entering `EditorScript` keyword. |
|
1 | Editor Scripting is an experimental feature that can be used to build levels by programmatically placing blocks. The editor is currently available in the beta version of [[ Fancade Web ]] by entering the `EditorScript` command in the [command line](fancade-web#command-line). |
|
2 | 2 | |
3 | *Practical and potential uses to be determined |
|
3 | ## Getting Started |
|
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! |
|
4 | 5 | |
5 | # Getting Started |
|
6 | 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. |
|
7 | ||
8 | Anyways, were here to learn about the basic concepts of JS and compare it to fancade scripting for better understanding. Lets start with variables! |
|
6 | ## Functions |
|
7 | So let's look at our first example. |
|
8 | ```js |
|
9 | // Set block at position (x, y, z) in level or open block |
|
10 | setBlock(x, y, z, prefabIndex); |
|
11 | ``` |
|
12 | We can ignore the first line, since it begins with `//`. This makes the editor ignore any code in the current line, but it can give us some hints on what the following line does.\\ |
|
13 | The second line starts with the function `setBlock`. You can imagine this as placing a script block with the aforementioned name. The following text represents the inputs given to this function, separated by `,` and enclosed by brackets. The line is then finished off with a `;`. So to put this in [[visual scripting]] therms, we are placing a block called `setBlock` and give it the inputs `x`, `y`, `z` and `prefabIndex`. |
|
14 | Those inputs were only placeholders, so let's put some values in it!\\ |
|
15 | ```js |
|
16 | setBlock(0, 0, 0, 3); |
|
9 | 17 | |
10 | 18 | ### Variables |
11 | 19 | 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: |