Login

Fancade Wiki

Updated Introduction to Editor Scripting.md (markdown)

... ...
@@ -61,12 +61,16 @@ setBlock(1, 0, 1, myBlocks[0]);
61 61
62 62
## Objects
63 63
```js
64
let blockIds = {};
65
// Store block ids in the object
66
myBlocks["Stone"] = findBlock("Stone");
67
myBlocks["Slate"] = findBlock("Slate");
68
```
69
Objects `{}` are similar to lists in that they can hold values for different indexes. However, they access their values using a string as index. For instance, this allows you to store blocks based on their name instead of their id.
64
let waterBlock = {
65
// Pre-define properties
66
collider: "box",
67
type: "normal"
68
};
69
70
// Adding or overriding properties
71
grassBlock.size = [8, 8, 8];
72
grassBlock.collider = "none";
70 73
```
74
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.
71 75
72 76
<!-- ToDo: Loops, Conditions -->
Fancade Wiki