# Methods

### Introduction

Functions pertaining to Map’s tile effects, object upload, and other convenient feature functions for maps are provided below.

<table><thead><tr><th width="217">Name</th><th>Description</th></tr></thead><tbody><tr><td>putTileEffect</td><td>Function to apply a tile effect to the specified coordinates</td></tr><tr><td>putObject</td><td>Function to place an object on the specified coordinates</td></tr><tr><td>putObjectMultiple</td><td>Function to install objects at once by entering coordinates to place objects in a two-dimensional array.</td></tr><tr><td>putObjectWithKey</td><td>Function to place an object with a key value on the specified coordinates</td></tr><tr><td>playObjectAnimation</td><td>Function to execute an object’s sprite animation on the specified coordinates</td></tr><tr><td>playObjectAnimationWithKey</td><td>Function to execute an object's sprite animation whose key value matches</td></tr><tr><td>moveObject</td><td>Function to move an object from one x and y axis coordinates to another x and y axis coordinates during an X amount of time</td></tr><tr><td>moveObjectWithKey</td><td>Function to move an object with a key value to the specified coordinates</td></tr><tr><td>clearAllObjects</td><td>Function to remove all objects created using ZEP script</td></tr><tr><td>getTile</td><td>Function to return the enum value of the tile at the x and y coordinates of the corresponding layer</td></tr><tr><td>hasLocation</td><td>Function to check if the corresponding location exists in the map and return true or false</td></tr><tr><td>getObjectsByType</td><td>Function to return the objects that correspond to Type</td></tr><tr><td>getTopObjectsByType</td><td>Function to return the top objects that correspond to Type</td></tr><tr><td>sayObjectWithKey</td><td>Function to display a word balloon above an object with a key value</td></tr></tbody></table>

## 📚 API Explanation and Example

<mark style="background-color:yellow;">**Methods at a Glance**</mark>

```jsx
// Applies tile effect to the specified coordinates 
Map.putTileEffect(x: number, y: number, tileID: TileEffectType)

// Places the object at the specified coordinates (Reference coordinates: Left-Top)
Map.putObject(x: number, y: number, dynamicResource: ScriptDynamicResource)

// Install objects at once by entering coordinates to place objects in a two-dimensional array
Map.putObjectMultiple(tileArray: array, type: PutObjectType, dynamicResource: ScriptDynamicResource, option: object);

// Places the object with a key value at the specified coordinates (Reference coordinates: Left-Top)
Map.putObjectWithKey(x: number, y: number, dynamicResource: ScriptDynamicResource, option: JsValue)

// Executes a sprite animation of the object at the specified coordinates 
// (must be preceded by putObject)
Map.playObjectAnimation(x: number, y: number, name: string, loop: number)

// Executes an object's sprite animation whose key value matches
Map.playObjectAnimationWithKey(key: string,) animName: string, repeatCount: number)

// Removes all objects created by the ZEP script 
Map.clearAllObjects()

// Moves the object from the corresponding coordinates to the target coordinates for time 
// (in seconds)
Map.moveObject(x: number, y: number, targetX: number, targetY: number, time: number)

// Moves the object with a key value to the target coordinates
Map.moveObjectWithKey(key: string, targetX: number, targetY: number, path:boolean = true)

// Returns the type value of the tile at the x and y coordinates of the corresponding layer
Map.getTile(layer: number, x: number, y: number)

// Checks if the corresponding location exists in the map and returns true or false
Map.hasLocation(locationName: string)

// Returns the objects that correspond to Type
Map.getObjectsByType(type: number)

// Returns the top objects that correspond to Type
Map.getTopObjectsByType(type: number)

// Displays a word balloon above an object with a key value
Map.sayObjectWithKey( key: string, message: string )
```

### putTileEffect

{% hint style="info" %}
&#x20;Map.putTileEffect(x: number, y: number, tileID: TileEffectType)
{% endhint %}

This function applies a tile effect to the specified coordinates.

**Parameters**

More information on TileEffectType can be found on the [<mark style="color:purple;">Tile Effect Type Detailed Explanation</mark> ](/zep-script/zep-script-guide/appendix/tileeffecttype-detailed-explanation.md)page.

<table><thead><tr><th width="101.33333333333331">Name</th><th width="147">Type</th><th>Description</th></tr></thead><tbody><tr><td>x, y</td><td>Number</td><td>Object’s x and y coordinates</td></tr><tr><td>tileID</td><td>TileEffectType</td><td>• TileEffectType.NONE: no effect<br>•TileEffectType.IMPASSABLE: players cannot pass<br>• TileEffectType.SPAWN: players spawn here<br>• TileEffectType.PORTAL: move players to a different location<br>•TileEffectType.PRIVATE_AREA: designates a private discussion area<br>•TileEffectType.SPOTLIGHT: designates a spotlight area<br>• TileEffectType.EMBED: adds a web link<br>• TileEffectType.LOCATION: designated area for ZEP script<br>•TileEffectType.AMBIENT_SOUND: sets background sounds<br>•TileEffectType.TILE_EMBED: embeds something from the web<br>•TileEffectType.WEB_PORTAL: a web portal<br>•TileEffectType.SPACE_PORTAL: a portal to another Space</td></tr></tbody></table>

**Example**

Set up an **IMPASSABLE** tile effect.

```jsx
// Activates function when q is pressed 
// **[App.addOnKeyDown](https://www.notion.so/Callbacks-7ac5078bab7c4f3180ae05463713581d) Explanation [(Link)](https://www.notion.so/Callbacks-7ac5078bab7c4f3180ae05463713581d)**
App.addOnKeyDown(81, function (player) {
	// Sets an impassible tile effect on coordinates 5, 5 
	Map.putTileEffect(5, 5, TileEffectType.IMPASSABLE);
});
```

### putObject

{% hint style="info" %}
Map.putObject(x: number, y: number, dynamicResource: ScriptDynamicResource, option: JsValue)
{% endhint %}

This function places the object at the specified coordinates. (Reference coordinates: Left-Top) → What are [**Reference Coordinates?**](broken://spaces/u4PFrNZjiq0L6ogrcQ8C)

To better understand ScriptDynamicResource, please refer to the [<mark style="color:purple;">Understanding Sprite Sheets</mark> ](/zep-script/zep-script-guide/appendix/understanding-spaces-and-maps.md)page.

> You can delete the object installed from script by sending the null value to parameter.
>
> ```
> Map.putObject(x, y, null);
> ```

**Parameters**

<table><thead><tr><th width="183.33333333333331">Name</th><th width="215">Type</th><th>Description</th></tr></thead><tbody><tr><td>x, y</td><td>Number</td><td>x, y coordinates of where the tile effect will be applied</td></tr><tr><td>dynamicResource</td><td>ScriptDynamicResource</td><td>Variable name of the saved sprite.</td></tr><tr><td>loop</td><td>Number</td><td>Specify the number of times to repeat the animation</td></tr><tr><td>option</td><td>Object</td><td>Input { overlap: true } in the parameter field to recognize the object from <a href="/pages/ANYzOPmajWGs923GTU3b"><mark style="color:purple;"><strong>App EventListener</strong></mark> </a>such as <strong>onObjectTouched</strong> and <strong>onObjectAttacked</strong><mark style="color:purple;">.</mark></td></tr></tbody></table>

**Example**

Create the blueman object.

<div align="left"><figure><img src="/files/AShHrg6On5tNoByqrirb" alt=""><figcaption></figcaption></figure></div>

```jsx
// Creates an blueman.png and save the blueman variable
let blueman = App.loadSpritesheet("blueman.png");
// Activates function when q is pressed  
App.addOnKeyDown(81, function (player) {
	// Executes the blueman object on coordinates 5, 5 
	Map.putObject(5, 5, blueman, {overlap: true});
});
// Activates function when w is pressed
App.addOnKeyDown(81, function (player) {
	// Delets the object on corrdinates 5, 5
	Map.putObject(5, 5, null);
});
```

### putObjectMultiple

{% hint style="info" %}
Map.putObjectMultiple(tileArray: array, type: PutObjectType, dynamicResource: ScriptDynamicResource, option: object);
{% endhint %}

This function installs objects at once by entering coordinates to place objects in a two-dimensional array. This allows you to reduce the load when you install many objects at once.

**Parameters**

<table><thead><tr><th width="121.33333333333331">Name</th><th width="152">Type</th><th>Description</th></tr></thead><tbody><tr><td>tileArray</td><td>Array</td><td>Enter a two-dimensional array defining the coordinates where you want to place the objects. (Maximum length limited to 10)</td></tr><tr><td>type</td><td>PutObjectType</td><td><p><code>PutObjectType.STROKE</code></p><ul><li>Once a path is created by connecting the coordinates defined in the tileArray array in order, objects are placed in all coordinates along the created path.</li></ul></td></tr><tr><td>dynamicResource</td><td>ScriptDynamicResource</td><td>Image resources loaded using App.loadSpriteSheet</td></tr><tr><td>option</td><td>Object</td><td>In order for App EventListener to recognize an object, such as onObjectTouched and onObjectAttached, you should enter <code>{overlap:true}</code> in the parameter box.</td></tr></tbody></table>

**Example**

Place objects in a square or circle.

![](/files/Jp9LpmkAAFk5J0zaiq78)

![](/files/ScsxQoE0qa8DmQJ1ga5T)![](/files/QGrXwTWyJd0dBgYgWF7q)

```javascript
const _mark = App.loadSpritesheet("mark.png");

// Activates function when q is pressed - Place in a square
App.addOnKeyDown(81, function (player) {
	const tileArray = [
		[5, 5],
		[9, 5],
		[9, 9],
		[5, 9],
		[5, 5],
	];
	Map.putObjectMultiple(tileArray, PutObjectType.STROKE, _mark, { overlap: true });
});

// Activates function when w is pressed - Place in a circle
App.addOnKeyDown(87, function (player) {
	const tileArray = [
		[10, 5],
		[8, 7],
		[8, 10],
		[10, 12],
		[13, 12],
		[15, 10],
		[15, 7],
		[13, 5],
		[10, 5],
	];
	Map.putObjectMultiple(tileArray, PutObjectType.STROKE, _mark, { overlap: true });
});
```

###

### putObjectWithKey

{% hint style="info" %}
Map.putObjectWithKey(x: number, y: number, dynamicResource: ScriptDynamicResource, option: JsValue)
{% endhint %}

This function places an object on the specified coordinates (Reference coordinates: Left-Top)

**Parameters**

<table><thead><tr><th width="183.33333333333331">Name</th><th width="215">Type</th><th>Description</th></tr></thead><tbody><tr><td>x, y</td><td>Number</td><td>x, y coordinates of where the object will be placed</td></tr><tr><td>dynamicResource</td><td>ScriptDynamicResource</td><td>Variable name of the saved sprite.</td></tr><tr><td>option</td><td>Object</td><td>Sets the attributes including key values, moveSpeed, overlap, useDirAnim etc.</td></tr></tbody></table>

**Example**

Create the blueman object with a key value.

![](/files/8OylzTNLVOH3v4o6nnfW)

```bash
let blueman = App.loadSpritesheet("blueman.png");
// Activates function when q is pressed
App.addOnKeyDown(81, function (player) {
	Map.putObjectWithKey(18, 6, blueman, {
		overlap: true,
		movespeed: 100, // move speed, default: 80
		key: "TestBlueMan", // key value
		useDirAnim: true // Option to play animation after recognizing the direction
	});
});
```

### getObjectWithKey

{% hint style="info" %}
Map.getObjectWithKey(key: String)
{% endhint %}

This function gets the information of the object with the corresponding key value.

**Parameter**

<table><thead><tr><th width="108.33333333333331">Name</th><th width="160">Type</th><th>Description</th></tr></thead><tbody><tr><td>key</td><td>String</td><td>The key value of the object to get information from</td></tr></tbody></table>

**Example**

Create an object with a key value and display the related data.

![](/files/DBg38a0Ks2yep215mhXt)

```bash
let blueman = App.loadSpritesheet("blueman.png");
App.onStart.Add(function() {
	Map.putObjectWithKey(18, 6, blueman, {
		overlap: true,
		movespeed: 80,
		key: "TestBlueMan", // Key value
	});
});
// Activates function when q is pressed
App.addOnKeyDown(81, function (player) {
	let object_blueman = Map.getObjectWithKey("TestBlueMan");
	for(let data in object_blueman){
		App.sayToAll(`${data}: ${object_bluemane[data]}`)
	}
})
```

### playObjectAnimation

{% hint style="info" %}
Map.playObjectAnimation(x: number, y: number, name: string)
{% endhint %}

This function activates the object animation at the corresponding coordinates.

The above function must be preceded by the Map.putObject function.

Check the [Understanding Sprite Sheets](https://app.gitbook.com/o/-MkvEtFn2kFBYSN4_5rX/s/-MkvEvcz_LX5eDyvl13E/~/changes/w3N0YzSI1GwzatxlXlfM/zep-script-guide-v2/appendix/understanding-spaces-and-maps) page if it’s your first time hearing about sprite sheets.

**Parameters**

<table><thead><tr><th width="114.33333333333331">Name</th><th width="101">Type</th><th>Description</th></tr></thead><tbody><tr><td>x, y</td><td>Number</td><td>x, y coordinates of where the tile effect will be applied</td></tr><tr><td>name</td><td>String</td><td><code>let variable = App.loadSpritesheet(...)</code><br>The saved variable name of the sprite must be inputted as below:<br>→ ‘#’ + variable.id</td></tr></tbody></table>

**Example**

Set up a dancing blueman object.

<div align="left"><figure><img src="/files/yUySk4jJ9d7BulSPOMVb" alt=""><figcaption></figcaption></figure> <figure><img src="/files/2aWVd5vonPnzIAG7I8ME" alt=""><figcaption></figcaption></figure></div>

```jsx
// One frame's size 48x64
let blueman_dance = App.loadSpritesheet(
	"blueman.png",
	48,
	64,
	[20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37], // Animation comprised of 21st ~ 38th image
	8
);
// Activates function when q is pressed 
App.addOnKeyDown(81, function (player) {
	Map.putObject(5, 5, blueman_dance, { overlap: true });
	Map.playObjectAnimation(5, 5, "#" + blueman_dance.id, -1);
});
```

### playObjectAnimationWithKey

{% hint style="info" %}
Map.playObjectAnimation(key: string, animName: string, repeatCount: number)
{% endhint %}

This function executes the object's sprite animation whose key value matches.

The <mark style="color:purple;">`Map.putObjectWithKey`</mark> function must preceed this function.

If you are not familiar with sprite images, please refer to the [Understanding Sprite Sheets ](/zep-script/zep-script-guide/appendix/understanding-sprite-sheets.md)page!

**Parameters**

<table><thead><tr><th width="153.33333333333326">Name</th><th width="137">Type</th><th>Description</th></tr></thead><tbody><tr><td>key</td><td>String</td><td>The key value of the object</td></tr><tr><td>animName</td><td>String</td><td>The name of the animation to play</td></tr><tr><td>repeatCount</td><td>Number</td><td>Specify the number of times to repeat the animation ("-1" means infinite.)</td></tr></tbody></table>

**Example**

Set up a dancing blueman object.

<div align="left"><figure><img src="/files/yUySk4jJ9d7BulSPOMVb" alt=""><figcaption><p>blueman_sprite</p></figcaption></figure></div>

```jsx
var blueman_sprite = App.loadSpritesheet(
	"blueman.png",
	48,
	64,
	{
		left: [5, 6, 7, 8, 9],
		up: [15, 16, 17, 18, 19],
		down: [0, 1, 2, 3, 4],
		right: [10, 11, 12, 13, 14],
		dance: [20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37],
		idle: [0],
	},
	8
);

// Activates function when q is pressed 
App.addOnKeyDown(81, function (player) {
	Map.putObjectWithKey(10, 10, blueman_sprite, {
		overlap: true,
		movespeed: 80, // default: 80
		key: "blueman",
	});
	// play the "dance" animation
	Map.playObjectAnimationWithKey("blueman", "dance", -1);
});
```

### moveObject

{% hint style="info" %}
Map.moveObject(x: number, y: number, targetX: number, targetY: number, time: number)
{% endhint %}

This function moves the object from the object’s x and y coordinates to the target x and y coordinates for a certain amount of time (secs).

The above function must be preceded by the **Map.putObject** function.

Check the[ Understanding Sprite Sheets](https://app.gitbook.com/o/-MkvEtFn2kFBYSN4_5rX/s/-MkvEvcz_LX5eDyvl13E/~/changes/w3N0YzSI1GwzatxlXlfM/zep-script-guide-v2/appendix/understanding-spaces-and-maps) page if it’s your first time hearing about sprite sheets.

**Parameters**

<table><thead><tr><th width="175.33333333333331">Name</th><th width="128">Type</th><th>Description</th></tr></thead><tbody><tr><td>x, y</td><td>Number</td><td>Object’s x and y coordinates</td></tr><tr><td>targetX, targetY</td><td>Number</td><td>Target location’s x and y coordinates</td></tr><tr><td>time</td><td>Number</td><td>Time(seconds) to reach the target location.</td></tr></tbody></table>

**Example**

Move the blueman object.

<div align="left"><figure><img src="/files/MBq8b1sBqrCZ5AbTt0Of" alt=""><figcaption></figcaption></figure> <figure><img src="/files/F57K5QOmgKkjLEFrvg5v" alt=""><figcaption></figcaption></figure></div>

```jsx
// One frame's size 48x64
let blueman_move_right = App.loadSpritesheet(
	"blueman.png",
	48,
	64,
	[10, 11, 12, 13, 14], // Animation comprised of the 11th ~ 15th images
	8
);
// Activates function when q is pressed  
// **[App.addOnKeyDown](https://www.notion.so/Callbacks-7ac5078bab7c4f3180ae05463713581d) Explanation [(Link)](https://www.notion.so/Callbacks-7ac5078bab7c4f3180ae05463713581d)**
App.addOnKeyDown(81, function (player) {
	Map.putObject(5, 5, blueman_right, { overlap: true });
	Map.playObjectAnimation(5, 5, "#" + blueman_right, -1);
	Map.moveObject(5, 5, 10, 5, 3) // At (5,5) move to (10,5) in 3 seconds
});
```

### moveObjectWithKey

{% hint style="info" %}
Map.moveObjectWithKey(key: string, targetX: number, targetY: number, path:boolean = true)
{% endhint %}

This function moves an object with a key value to the specified coordinates.

💡 When "path" is "true", the object doesn't move when the target location is an impassable tile or unreachable.

**Parameters**

<table><thead><tr><th width="171.33333333333331">Name</th><th width="134">Type</th><th>Description</th></tr></thead><tbody><tr><td>key</td><td>String</td><td>Object's key value</td></tr><tr><td>targetX, targetY</td><td>Number</td><td>Target location’s x and y coordinates</td></tr><tr><td>path</td><td>Boolean</td><td>true: cannot pass an impassable tile<br>false: can pass an impassable tile</td></tr></tbody></table>

**Example**

How `moveObjectWithKey` works

![](/files/0pB7yFtfS1sCDFdXNtKm)

```jsx
let blueman = App.loadSpritesheet('blueman.png', 48, 64, {
    left: [5, 6, 7, 8, 9], // Image that moves to the left
    up: [15, 16, 17, 18, 19],
    down: [0, 1, 2, 3, 4],
    right: [10, 11, 12, 13, 14],
    dance: [20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37],
    down_jump: [38],
    left_jump: [39],
    right_jump: [40],
    up_jump: [41],
}, 10);
// Activates function when q is pressed
App.addOnKeyDown(81, function (player) {
	Map.putObjectWithKey(18, 6, blueman, {
		overlap: true,
		movespeed: 50, // default: 80
		key: "TestBlueMan",
		useDirAnim: true // Option to play animation after recognizing the direction
	});
	Map.moveObjectWithKey("TestBlueMan", 10, 10, true);
});
```

### clearAllObjects()

{% hint style="info" %}
Map.clearAllObjects()
{% endhint %}

This function removes all objects created by the ZEP script.

**Parameter**

* None

**Example**

Remove all created objects.

<div align="left"><figure><img src="/files/IwaGkHy7t9jE1ER3p8kr" alt=""><figcaption></figcaption></figure></div>

```jsx
let blueman = App.loadSpritesheet("blueman.png");

// Activates function when q is pressed 
// **[App.addOnKeyDown](https://www.notion.so/Callbacks-7ac5078bab7c4f3180ae05463713581d) Explanation [(Link)](https://www.notion.so/Callbacks-7ac5078bab7c4f3180ae05463713581d)**
App.addOnKeyDown(81, function (player) {
	// Creates 5 blueman objects starting from coordinates 5, 5 
	Map.putObject(5, 5, blueman, {overlap: true});
	Map.putObject(6, 5, blueman, {overlap: true});
	Map.putObject(7, 5, blueman, {overlap: true});
	Map.putObject(8, 5, blueman, {overlap: true});
	Map.putObject(9, 5, blueman, {overlap: true});
});

// Activates function when w is pressed 
App.addOnKeyDown(87, function (player) {
	// Removes all objects created using script
	Map.clearAllObjects();
});
```

***

### getTile

{% hint style="info" %}
Map.getTile(layer: number, x: number, y: number)
{% endhint %}

Return the type value of the tile at the x and y coordinates of the corresponding layer. If no tile, returns "-1."

**Parameters**

<table><thead><tr><th width="134">Name</th><th width="123.33333333333331">Type</th><th>Description</th></tr></thead><tbody><tr><td>layer</td><td>Number</td><td>Values corresponding to the layer<br>0 = Floor (floor tile),<br>1 = WALL (wall tile),<br>2 = TileEffect (tile effects),<br>3 = Object (objects),<br>5 = TopObject (top objects),</td></tr><tr><td>x, y</td><td>Number</td><td>X and Y coordinates</td></tr></tbody></table>

**Example**

Check the types of all objects in the map.

```jsx
const LayerType = {
	FLOOR: 0,
	WALL: 1,
	TILE_EFFECTS: 2,
	OBJECTS: 3,
	TOP_OBJECTS: 5,
};
// Activates function when q is pressed 
App.addOnKeyDown(81, function (player) {
	let layer = LayerType.OBJECTS;
	for (let x = 0; x < Map.width; x++) {
		for (let y = 0; y < Map.height; y++) {
			let data = Map.getTile(layer, x, y);
			if (data >= 0) {
				App.sayToAll(`(${x},${y})  type: ${data}`);
			}
		}
	}
});
```

### hasLocation

{% hint style="info" %}
Map.hasLocation(locationName: String)
{% endhint %}

This function checks if the corresponding location exists in the map and returns true or false accordingly.

**Parameter**

| Name         | Type   | Description          |
| ------------ | ------ | -------------------- |
| locationName | String | Name of the location |

**Example**

Create a function that checks if the location is installed.

```jsx
// Activates function when q is pressed
App.addOnKeyDown(81, function (player) {
	if(Map.hasLocation("test")){
		App.sayToAll("Test location is installed.")
	} else {
		App.sayToAll("Test location is not installed.")
	}
});
```

***

### getObjectsByType

{% hint style="info" %}
Map.getObjectsByType(type: numer) : array
{% endhint %}

This function returns the objects that correspond to Type.

**Parameter**

| Name | Type   | Description              |
| ---- | ------ | ------------------------ |
| type | Number | Type value of the object |

**Example**

Check all type of objects.

```
const ObjectType = {
    NONE : 0,
    SHOW_NOTE : 1,
    SHOW_IMAGE : 2,
    PASSWORD_DOOR : 3,
    LINK_WEBSITE : 4,
    EMBED_WEBSITE : 5,
    API_CALL : 6,
    REPLACE_IMAGE : 7,
    NFT_GIVEAWAY : 8,
    NFT_DOOR : 9,
    POST_MESSAGE : 10,
    SHOW_CHAT_BALLOON : 11,
    FT_DOOR : 12,
    POST_MESSAGE_TO_APP : 13,
    DONATION_DOOR : 14,
    IMPASSABLE : 15,
    INTERACTION_WITH_ZEPSCRIPTS : 16,
    TOKEN_DONATION_DOOR : 17,
    CHANGE_OBJECT : 18,
    ANIMATION : 19,
}
// Activates function when q is pressed
App.addOnKeyDown(81,function(player){
    for(let key in ObjectType){
        let type = ObjectType[key];
        let arr = Map.getObjectsByType(type);
        let index = 0;
        for(let obj of arr){
            for(let key in obj){
                App.sayToAll(`${key}: ${obj[key]}`);        
            }
        }
    }
})
```

![](/files/rPIIzV4hPoyKQ1DtSLIP)

***

### getTopObjectsByType

{% hint style="info" %}
Map.getTopObjectsByType(type: numer) : array
{% endhint %}

This function returns the top objects that correspond to each type.

**Parameter**

| Name | Type   | Description              |
| ---- | ------ | ------------------------ |
| type | Number | Type value of the object |

**Example**

Check all types of top objects.

```jsx
const ObjectType = {
    NONE : 0,
    SHOW_NOTE : 1,
    SHOW_IMAGE : 2,
    PASSWORD_DOOR : 3,
    LINK_WEBSITE : 4,
    EMBED_WEBSITE : 5,
    API_CALL : 6,
    REPLACE_IMAGE : 7,
    NFT_GIVEAWAY : 8,
    NFT_DOOR : 9,
    POST_MESSAGE : 10,
    SHOW_CHAT_BALLOON : 11,
    FT_DOOR : 12,
    POST_MESSAGE_TO_APP : 13,
    DONATION_DOOR : 14,
    IMPASSABLE : 15,
    INTERACTION_WITH_ZEPSCRIPTS : 16,
    TOKEN_DONATION_DOOR : 17,
    CHANGE_OBJECT : 18,
    ANIMATION : 19,
}
// Activates function when q is pressed
App.addOnKeyDown(81,function(player){
    for(let key in ObjectType){
        let type = ObjectType[key];
        let arr = Map.getTopObjectsByType(type);
        let index = 0;
        for(let obj of arr){
            for(let key in obj){
                App.sayToAll(`${key}: ${obj[key]}`);        
            }
        }
    }
})
```

***

### sayObjectWithKey

{% hint style="info" %}
Map.sayObjectWithKey( key: string, message: string )
{% endhint %}

This function displays a word balloon above an object with a key value.

**Parameters**

<table><thead><tr><th width="160">Name</th><th width="115.33333333333331">Type</th><th>Description</th></tr></thead><tbody><tr><td>key</td><td>String</td><td>The key value of the object</td></tr><tr><td>message</td><td>String</td><td>Message to display in a word balloon</td></tr></tbody></table>

**Example**

Display a word balloon above an object with a key value.

![](/files/oSHGdmvjHYhhH8v1t8PD)

{% file src="/files/0jvNGI6SFS2fnb1MSz6h" %}

```javascript
const objectKey = "TestBlueMan";
// Activates function when q is pressed
App.addOnKeyDown(81, function (player) {
	Map.putObjectWithKey(18, 6, blueman, {
		npcProperty: { name: "BlueMan", hpColor: 0x03ff03, hp: 100, hpMax: 100 },
		overlap: true,
		movespeed: 100, 
		key: objectKey, 
		useDirAnim: true
	});
});

// Activates function when w is pressed
App.addOnKeyDown(87, function(player){
    Map.sayObjectWithKey(objectKey, `I'm BlueMan!`)
})
```

### Appendix

[Understanding Sprite Sheets](/zep-script/zep-script-guide/appendix/understanding-sprite-sheets.md)

[TileEffectType Detailed Explanation](/zep-script/zep-script-guide/appendix/tileeffecttype-detailed-explanation.md)

[What are Reference Coordinates?](/zep-script/zep-script-guide/appendix/what-are-reference-coordinates.md)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.zep.us/zep-script/zep-script-api/scriptmap/methods.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
