CollisionFunction and actionButtonFunction

When a player collides with an object, the player triggers that object's collisionFunction. When a player collides with an object and then presses the action button, that triggers that object's actionButtonFunction.

The collisionFunction and actionButtonFunction are strings containing escaped javascript commands. They are set to empty by default.

To add/modify a collisionFunction or actionButtonFunction

 * 1) In the >> command window, select Object commands > Object template commands > Modify object template > Collision function (or Action-button function).
 * 2) Replace the   placeholder with the name of the Object template you wish to add a function to. Do not remove the 'apostrophes'.
 * 3) Press execute. A prompt will appear. Why does a prompt appear?
 * 4) Enter the desired javascript command(s) into the prompt and press OK. To reference an object's self, use objectSelf in your command(s) (see below)

Using objectSelf
When a player interacts with an object, sometimes you want to change something about the individual object itself instead of the object's template. To achieve this, AsciiMason provides a READ-ONLY variable called objectSelf you can use, which stores data about the object the player is interacting with. READ-ONLY means that you cannot modify an object by modifying objectSelf. For example, if you execute, it will not change the x coordinate of the object to 3. However, you can use  to get the current x coordinate of the object.

Attributes of objectSelf
The attributes of objectSelf are the same as the attributes of myObject when calling


 * The x coordinate of the object you referenced
 * The y coordinate of the object you referenced
 * The name of the layer the object lives in
 * The name of the object template the object uses.
 * The unique ID of the object

To actually modify the object with a command such as  or , simply use   as the argument.

Using objectSelf in a dialogue tree
Dialogue trees in AsciiMason are not tied to an object in your game (see Dialogue Trees). This means that, while you can reference objectSelf in a dialogue tree function, objectSelf could refer to any object near the player that has a collisionFunction or actionButtonFunction. If there is more than one object that meets this criteria, AsciiMason will default to the object furthest to the right and furthest below the player.

What counts as a collision?
See: Layers

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/action button 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/action button function, the player must be standing over it and collision must be enabled for that layer.