Object Templates

Every object in the game world follows an object template. The object template describes the object's attributes such as its color, font, character (the actual ASCII text the object displays as), and more.

## How to...

### Browse object templates

1. Set your cursor to "cursor:paint" using the cursor button in the upper right corner.
2. Click the arrow buttons (or tap the Z and X keys) to switch between object templates.

### With commands...

#### Create a new object template

1. In the >> command window, select Object commands > Object template commands > New object template.
2. Replace these placeholders:
	* `TEMPLATE_NAME :` String. The name of your object template. Do not remove the 'apostophes'.
	* `CHARACTER :` String. The ASCII character you would like your object template to display as. (For example, to create a smiley person, set the character attribute to ☻). Do not remove the 'apostrophes'.
	* If you wish, modify any other attributes of the object template such as its color, font, or functions.
3. Press "execute". You will see the new object template if you set your cursor to "cursor:paint" (using the cursor button in the upper right corner) and browse through your object templates using the arrow buttons (or Z and X keys).

#### Delete an object template

1. In the >> command window, select Object commands > Object template commands > Delete object template.
2. Replace this placeholder:
	* `TEMPLATE_NAME :` String. The name of the object template you wish to delete. Do not remove the 'apostrophes'
3. Press "execute". You will see the object template is missing if you browse through your object templates.

## Attributes

`game.objectTemplates['TEMPLATE_NAME'] = {`

`"character":"CHARACTER", //the unicode character this object will display as`

`"font":"default",`

`"color":[255, 255, 255, 255], //RGBA values (A = alpha/opacity)`

`"tags":[],`

`"inventorySettings":`

`{`

`'appears':true,`

`'appearsZero':false,`

`'canBeNegative': false,`

`"function": ""`

`},`

`"collisionFunction": "",`

`"actionButtonFunction": ""`

`};`

### character

String. The ASCII character an object displays as.

Ex. a smiley person in your game may have the character "☻"

### font

String. The name of the font the object displays with. As of version 1.0, this can be set to either 'default' or 'creatures', which are both 8 px fonts.

`Ex. "default" or "creatures"`

### color

Array. A list of RGBA (red, green, blue, alpha) values for the color of the object template.

Ex. for a bright red color `[255,0,0,255]`

### tags

Array. A list of strings that describe the object template. Objects can be referenced by tag in commands by opening the command window and selecting > Object Commands > Individual Object Commands > Reference an Object > Reference Object by Tag.

`Ex. ["NPC", "wizard-class"]`

### inventorySettings

#### appears

Bool. When set to true, the object will be visible when added to the player's inventory. When set to false, the object will never be visible in the player's inventory.

`Ex. true or false`

#### appearsZero

Bool. When set to true, the object will be visible in the player's inventory even when its inventory count is zero (when the player has zero of this object).

`Ex. true or false`

#### canBeNegative

Bool. When set to true, the player can have a negative count of this object in their inventory. When set to false, the inventory count of this object is not allowed to go below zero.

`Ex. true or false`

#### function

String. The javascript command that is executed when this object is selected in the player's inventory.

`Ex. "dialogueLine(7);"`

### collisionFunction

*main article: collisionFunction and actionButtonFunction*

String. The javascript command that is executed when the player collides with this object.

`Ex. "addToInventory('xp', 1)"`

### actionButtonFunction

*main article: collisionFunction and actionButtonFunction*

String. The javascript command that is executed when the player collides with this object *and then* presses the action button. This can be used to initiate dialogue by setting this value to `'dialogueLine(DIALOGUE_ID_HERE);'`.

`Ex. "dialogueLine(7);"`