Objects

Objects are ASCII characters that can be inserted into the game world or the player's inventory. Everything you see and interact with in an AsciiMason game is an object. Objects are based on object templates. To modify attributes like an object's color, character, font, or functions, **you will have to modify the object template, not the object itself.** Every object in the world has a unique ID for referencing in commands.

## How to...

### Paint objects into the game world

1. Switch to edit mode. See How to create an AsciiMason game
2. Click the cursor button in the upper right corner. Change it to "cursor:paint".
3. Use the left and right arrow buttons under the cursor button (OR the Z and X keys) to select which object template you're painting.
4. Click the layer button in the upper right corner to change which layer you are painting into. See Layers.
5. Click and drag anywhere in the game window to paint an object there.
6. To stop painting, press the cursor button until it reads "cursor:none".

### Erase objects

1. Click the cursor button in the upper right corner. Change it to "cursor:erase"
2. Click the layer button in the upper right corner to change which layer you are erasing in. See Layers.
3. Click and drag anywhere in the game window to erase objects there.
4. If the object is not being erased, you are erasing in the wrong layer. Press the layer button to change which layer you're in. See Layers.
5. To stop erasing, press the cursor button until it reads "cursor:none".

### See an object's ID

1. Hover over an object with your cursor. In the upper right corner, text will appear with the object's ID and the name of the object template it uses.
2. If you don't see this text appear, your cursor is in the wrong layer. Press the layer button to change which layer you're in. See Layers.

### With commands...

#### Move an object

1. In the >> command window, select Object commands > Individual object commands > Move object.
2. Replace these placeholders:
	* `OBJECT_ID_HERE :` Integer. The ID of the object you wish to move
	* `NEW_LAYER_NAME :` String. The name of the layer you wish to move this object to. (Do not remove the 'apostrophes')
	* `NEW_X_COORDINATE :` Integer. The x coordinate you wish to move this object to.
	* `NEW_Y_COORDINATE :` Integer. The y coordinate you wish to move this object to.

#### Reference an object by its ID

1. In the >> command window, select Object commands > Individual object commands > Reference an object > Reference object by ID.
2. Replace these placeholders:
	* `OBJECT_ID_HERE :` Integer. The ID of the object you wish to reference
3. The command above searches for the object with the ID you inputted and creates a READ-ONLY variable called myObject. myObject has several attributes you can use:
	* `myObject.x:` The x coordinate of the object you referenced
	* `myObject.y:` The y coordinate of the object you referenced
	* `myObject.layerName:` The name of the layer the object lives in
	* `myObject.template:` The name of the object template the object uses.
	* `myObject.id:` The unique ID of the object
4. **Important note:** myObject is READ-ONLY. That means that you cannot modify the object you referenced by modifying myObject. For example, you cannot change the x-coordinate of an object to by executing `myObject.x = 3`. To move an object, you must use `moveObject()` (see above). However, you can use `myObject.x` to get the x-coordinate of the object.
5. To actually modify the object with a command such as `moveObject()` or `deleteObject()`, simply use `objectSelf.id` as the argument.

#### More...

For more commands relating to individual objects, browse the >> command window.

## Attributes

Note that individual objects do not have an x, y coordinate attribute or a layer attribute like the player does. This is because of the way AsciiMason stores objects. See Structure of the Game World.

**You never need to reference these attributes** in Javascript commands. They are just here for context, so you can see that an object does not store its own position.

`{`

`"name": 'TEMPLATE_NAME',`

`"id": ID`

`}`

### name

String. The name of the object template that this object follows.

`Ex. "Vending Machine"`

### id

Integer. The unique ID of this object. Objects can be referenced by ID by opening the >> command window and selecting Object commands > Individual object commands > Reference an object > Reference object by ID.

`Ex. 7`