Updated Introduction to Editor Scripting.md (markdown)
commited
commit
ec2a69a0c432c058ba824c9db01a71059bbb6f25
... | ... | @@ -111,13 +111,13 @@ let myBlocks = {}; |
111 | 111 | myBlocks["My Block"] = findBlock("My Block"); |
112 | 112 | myBlocks["My New Block"] = findBlock("My New Block"); |
113 | 113 | ``` |
114 | Objects `{}` are quite 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. |
|
114 | Objects `{}` are quite similar to arrays. However, they instead use strings as an index. For instance, this allows you to store blocks based on their name instead of their id. |
|
115 | 115 | ``` |
116 | 116 | // Set blocks from the object |
117 | 117 | setBlock(0, 0, 3, myBlocks["My Block"]); |
118 | 118 | setBlock(1, 0, 3, myBlocks["My New Block"]); |
119 | 119 | ``` |
120 |
However, this also allows us to create objects with custom properties like this: |
|
120 |
This also allows you to create a structured group of values, called properties, which represents as single item: |
|
121 | 121 | ``` |
122 | 122 | // Create object with custom properties |
123 | 123 | let myBlock = { |
... | ... | @@ -127,7 +127,8 @@ let myBlock = { |
127 | 127 | id: findBlock("My Block") |
128 | 128 | }; |
129 | 129 | ``` |
130 | We can then access the properties by following the variable name by `.` and the name of the property: |
|
130 | ||
131 | If the name of the property can be considered a variable (it means it doesn't contain illegal characters such as spaces), after the variable name, instead of using `[""]`, we can instead use `.` and the property name next to it: |
|
131 | 132 | ```js |
132 | 133 | // Set block by accessing custom properties |
133 | 134 | setBlock(myBlock.x, myBlock.y, myBlock.z, myBlock.id); |