Layers

In the game world, objects are stored in layers, similarly to how layers work in image editors such as Photoshop. This allows the user to stack objects on top of each other in the same tile. The player exists in a layer just like all other objects (to modify the player's layer attribute, see Player).

Collision
Important distinction:

For objects that are on the same layer as the player:


 * The object will be impassible (player cannot pass through it) unless collision is disabled for that layer.
 * To activate the object's collision function, the player must be standing next to it and collision must be enabled for that layer.

For objects that are on a different layer from the player.


 * The object will always be passible (player can pass through it), regardless of whether collision is enabled.
 * To activate the object's collision function, the player must be standing over it and collision must be enabled for that layer.

Change which layer the cursor is in

 * 1) Click on the layer button at the top right corner of the screen until it shows the layer desired. This will allow you to paint and erase objects in the correct layer.

Add a new layer

 * 1) In the >> command window, select Layer commands > Add new layer
 * 2) Replace these placeholders:
 * 3) *  String. Whatever you wish to name this layer; can be anything. Do not remove the 'apostrophes'
 * 4) *  Integer. The index (position in line) you wish to give this layer in the array of layers. (See Layer Index below for detail)
 * 5) *  Bool. When set to false, layer becomes invisible.
 * 6) *  Bool. When set to false, player will not collide with objects in that layer. See the collisionEnabled attribute below for detail.
 * 7) Press "execute". You will see your new layer when pushing the layer button at the top right corner of the screen.

Delete a layer
(Warning: This deletes all objects currently in that layer)


 * 1) In the >> command window, select Layer commands > Delete layer
 * 2) Replace this placeholder:
 * 3) *  String. The name of the layer you wish to delete. Do not remove the 'apostrophes'
 * 4) Press "execute". You will no longer see this layer when pushing the layer button at the top right corner of the screen.

Change layer visibility

 * 1) In the >> command window, select Layer commands > Modify Layer > Change layer visibility
 * 2) Replace these placeholders:
 * 3) *  String. The name of the layer whose visibility you wish to change. Do not remove the 'apostrophes'.
 * 4) *  Bool. When set to true, layer will be visible. When set to false, layer will be invisible. This does not affect collision.
 * 5) Press "execute".
 * 6) Press "space" to refresh the screen. You will see that any objects in that layer are now visible/invisible.

Change whether layer has collision

 * 1) In the >> command window, select Layer commands > Modify Layer > Change whether layer has collision
 * 2) Replace these placeholders:
 * 3) *  String. The name of the layer whose collision you wish to change. Do not remove the 'apostrophes'.
 * 4) *  Bool. When set to true, layer will have collision. When set to false, layer will not have collision. This does not affect visibility.
 * 5) Press "execute".

Change a layer's position
(Changes the order in which layers are rendered; like dragging layers up and down in an image editor such as Photoshop)


 * 1) In the >> command window, select Layer commands > Modify Layer > Change layer position
 * 2) Replace these placeholders:
 * 3) *  String. The name of the layer whose index (position in the list) you wish to change. Do not remove the 'apostrophes'.
 * 4) *  Integer. The index (position in the list) you wish to change this layer to. See Layer Index below for more detail.
 * 5) Press "execute".

Layer Index
Many programming languages (including javascript) have an object type called an array. An array is a list of items. Arrays have a zero-based index. That means that the first item on the array has an index of 0, the second item has an index of 1, the third item has an index of 2, and so on.

In AsciiMason, layers are stored in an array. The first layer (the one on the bottom) has an index of 0. The second layer (second from the bottom) has an index of 1, and so on. The index of the layer at the top is equal to the number of layers minus 1.

Attributes
Notice that a layer does not store its own index as an attribute.

name
String. The name of the layer

visible
Bool. When set to false, layer becomes invisible. This does not affect collision.

collisionEnabled
Bool. When set to false, player will not collide with objects in that layer, even if they are on the same layer as the player. This will also disable the collisionFunction and actionButtonFunction of any objects in that layer.

chunks
Array. A list of chunkColumns in this layer. This should not be modified. For more detail, see Structure of the Game World.