# Field

### Introduction

These are the attribute values pertaining to players.

The player’s nickname ([<mark style="color:purple;">name</mark>](#id-name)), location ([<mark style="color:purple;">tileX / tileY</mark>](#tilex-tiley)), etc. can be viewed. The player’s spotlight ([<mark style="color:purple;">spotlight</mark>](#spotlight)) feature and hide ([<mark style="color:purple;">hidden</mark>](#hidden)) feature can be activated. The player’s movement speed ([<mark style="color:purple;">moveSpeed</mark>](#movespeed)) and image ([<mark style="color:purple;">sprite</mark>](#sprite)) can be adjusted. It’s also possible to utilize the Space's storage ([<mark style="color:purple;">storage</mark>](#storage)) for storing player values.

🔒 Fields with this icon are read-only fields that cannot be revised.

<table><thead><tr><th width="196">Name</th><th>Description</th></tr></thead><tbody><tr><td>🔒 id</td><td>Player ID value</td></tr><tr><td>name</td><td>Player Nickname value</td></tr><tr><td>title</td><td>Text to be displayed in yellow above an avatar’s nickname</td></tr><tr><td>🔒 role</td><td>A numerical value that represents a player’s permissions</td></tr><tr><td>🔒 tileX / tileY</td><td>The X and Y coordinate values where the avatar is standing</td></tr><tr><td>🔒 dir</td><td>A value representing the direction a player is looking</td></tr><tr><td>moveSpeed</td><td>A value representing the player’s movement speed</td></tr><tr><td>sprite</td><td>An avatar’s sprite image value</td></tr><tr><td>tag</td><td>Value storage space to assign required attribute values</td></tr><tr><td>hidden</td><td>If the value is set to true, the player is invisible</td></tr><tr><td>spotlight</td><td>Toggle player spotlight</td></tr><tr><td>🔒 disableVideo</td><td>Toggle player video</td></tr><tr><td>🔒 disableAudio</td><td>Toggle player audio</td></tr><tr><td>attackType</td><td>Player’s attack type when z is pressed</td></tr><tr><td>attackSprite</td><td>Player’s attack image value when z is pressed</td></tr><tr><td>attackParam1</td><td>Distance value that affects how far the attack image flies</td></tr><tr><td>attackParam2</td><td>Distance value available for attack<br>Only valid when <code>attackType</code> is set to 2 (ranged attack)</td></tr><tr><td>🔒 walletAddress</td><td>The player’s wallet address value</td></tr><tr><td>storage</td><td>Storage space for player values in the Space (limited to the Space)</td></tr><tr><td>🔒 isMobile</td><td>Whether the player is connected via mobile</td></tr><tr><td>🔒 isMoving</td><td>If the player is moving, returns True. If not, returns False</td></tr><tr><td>🔒 isJumping</td><td>If the player is jumping, returns True. If not, returns False</td></tr><tr><td>customData</td><td>Can read the URL query string and save the value</td></tr><tr><td>displayRatio</td><td>Zoom in or out player's display</td></tr><tr><td>titleColor</td><td>Player's title color</td></tr><tr><td>🔒 emailHash</td><td>The hash value of the player's email</td></tr><tr><td>🔒 isGuest</td><td>If the player is not signed in, returns True.</td></tr></tbody></table>

## 📚 API Description and Examples

### id , name

{% hint style="info" %}
player.id: Number \
player.name: String
{% endhint %}

Calls the player ID and nickname values.

**Example**

Make the player’s ID and nickname value display when a player enters.

```jsx
// Activates function when a player enters
App.onJoinPlayer.Add(function(player){
  App.sayToAll(`id: ${player.id} name: ${player.name}`);
})
```

### title

{% hint style="info" %}
player.title: String
{% endhint %}

Title is a yellow text that displays above the avatar’s nickname.

**Example**

Set up a title for a player when they enter.

```jsx
// Activates function when a player enters 
App.onJoinPlayer.Add(function(player){
	player.title = "title";
	player.sendUpdated();
})
```

### role

{% hint style="info" %}
player.role: Number
{% endhint %}

Role is the player’s permission roles’ number value.

The following values will be displayed depending on the player’s role.

<table><thead><tr><th width="146">Role</th><th width="137">Number</th><th width="154">Role</th><th width="168">Number</th></tr></thead><tbody><tr><td>Guest</td><td>-1</td><td>Staff</td><td>2000</td></tr><tr><td>Member</td><td>0</td><td>Admin</td><td>3000</td></tr><tr><td>Editor</td><td>1000</td><td>Owner</td><td>3001</td></tr></tbody></table>

**Example**

Display the permission role value in the chat screen.

```jsx
// Activates function when q is pressed 
// **[App.addOnKeyDown Description (Link)](https://www.notion.so/Callbacks-7ac5078bab7c4f3180ae05463713581d)**
App.addOnKeyDown(81,function(player){
	App.sayToAll(`${player.name}'s permissions: ${player.role}`)
})
```

### tileX, tileY

{% hint style="info" %}
player.tileX: Number \
player.tileY: Number
{% endhint %}

The x axis value and y axis value of where the player’s avatar is standing.

**Example**

Display my avatar’s x and y coordinates.

```jsx
// Activates function when q is pressed 
// **[App.addOnKeyDown Description (Link)](https://www.notion.so/Callbacks-7ac5078bab7c4f3180ae05463713581d)**
App.addOnKeyDown(81,function(player){
	App.sayToAll(`Current Coordinates: (${player.tileX}, ${player.tileY})`)
})
```

### dir

{% hint style="info" %}
player.dir: Number
{% endhint %}

The direction the player’s avatar is looking.

The following values are displayed depending on the direction the avatar is looking.

![](https://3059601135-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MkvEvcz_LX5eDyvl13E%2Fuploads%2F69KYXgvhvL9gdFKz2qyU%2Fimage.png?alt=media\&token=c3d5251b-2feb-46ce-bac9-b4ae9eb77957)

| Direction | Number | Direction    | Number |
| --------- | ------ | ------------ | ------ |
| Left      | 1      | Top-Left     | 5      |
| Up        | 2      | Bottom-Left  | 6      |
| Right     | 3      | Top-Right    | 7      |
| Down      | 4      | Bottom-Right | 8      |

**Example**

Display the value of where the avatar is looking.

```jsx
// Activates function when q is pressed 
// App.addOnKeyDown Description
App.addOnKeyDown(81,function(player){
	App.sayToAll(`Direction the avatar is looking: ${player.dir}`)
})
```

### moveSpeed

{% hint style="info" %}
player.moveSpeed: Number
{% endhint %}

This is the player’s movement speed value. (Default Value: 80)

If the movement speed value is 0, the player cannot move.

**Example**

Increase the movement speed when q is pressed.

```jsx
// Activates function when q is pressed 
// App.addOnKeyDown Description 
App.addOnKeyDown(81,function(player){
	player.moveSpeed = 150;
	player.sendUpdated();
})
```

### sprite

{% hint style="info" %}
player.sprite: ScriptDynamicResource
{% endhint %}

A sprite image of the player’s avatar. (Resets to the default avatar image when inputting **null**)

Check the [<mark style="color:purple;">Understanding Sprite Sheets</mark>](https://docs.zep.us/zep-script/zep-script-guide/appendix/understanding-sprite-sheets) page if it’s your first time hearing about sprite images.

**Example**

Apply the Paintman-Blueman image as the avatar image.

{% file src="<https://3059601135-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MkvEvcz_LX5eDyvl13E%2Fuploads%2FqCKJImBIrrpo1kX5N3bI%2F%EC%98%88%EC%A0%9C_loadSpritesheet.zip?alt=media&token=a1b0ad74-a090-4ffe-9b3d-5c281b37e2f1>" %}

<div align="left"><figure><img src="https://3059601135-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MkvEvcz_LX5eDyvl13E%2Fuploads%2FmpPeXhohhxdXgUOQOV1U%2FUntitled.png?alt=media&#x26;token=be474daf-895c-44f5-894b-b21abfdda8c5" alt=""><figcaption></figcaption></figure></div>

```jsx
// One frame's size 48x64
let blueman = App.loadSpritesheet('blueman.png', 48, 64, {
    left: [5, 6, 7, 8, 9], // left direction facing image
    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],
}, 8);
// Changes avatar's image when player enters
App.onJoinPlayer.Add(function(player){
	player.sprite = blueman;
	player.sendUpdated();
});
```

### tag

{% hint style="info" %}
player.tag: Any
{% endhint %}

Give necessary attribute values to a player by using tag.

**Example**

Give a player the ‘alive’ attribute value. The ‘alive’ attribute value is a deliberately created attribute.

If the attribute is unused, it won’t be a useful attribute value. In this case, the "alive" attribute value can check if a player has been eliminated from a game or not.&#x20;

```jsx
// Activates function when a player enters 
App.onJoinPlayer.Add(function (player) {
	player.tag = {
		alive: true,
	};
	player.sendUpdated();

	App.sayToAll(`alive: ${player.tag.alive}`);
});
```

### hidden

{% hint style="info" %}
player.hidden: Boolean
{% endhint %}

If the hidden attribute value is true, the corresponding player is not visible to other players.

{% hint style="danger" %}
The avatar in a hidden state is not visible, but it is possible to connect the video and audio.
{% endhint %}

**Example**

Give an avatar the hidden attribute to make the avatar not visible to other players.

```jsx
// Activates function when q is pressed 
// App.addOnKeyDown Description
App.addOnKeyDown(81,function(player){
	player.hidden = true;
	player.sendUpdated();
});
```

### spotlight

{% hint style="info" %}
player.spotlight: Boolean
{% endhint %}

This activates or deactivates the player’s spotlight feature.

**Example**

Make a function that turns the spotlight feature ON or OFF by pressing q.

```jsx
// Activates function when q is pressed
// App.addOnKeyDown Description
App.addOnKeyDown(81,function(player){
	if(player.spotlight){
		player.spotlight = false;
	}
	else{
		player.spotlight = true;
	}
	player.sendUpdated();
});
```

### disableVideo, disableAudio

{% hint style="info" %}
player.disableVideo: Boolean \
player.disableAudio: Boolean
{% endhint %}

This activates or deactivates the player’s video/audio features.

**Example**

Display in the chat screen if the video and/or audio are deactivated or not.

```jsx
// Activates function when q is pressed 
// App.addOnKeyDown Description 
App.addOnKeyDown(81, function (player) {
	App.sayToAll(`video activation or deactivation: ${player.disableVideo}`);
	App.sayToAll(`audio activation or deactivation: ${player.disableAudio}`);
});
```

### attackType

{% hint style="info" %}
player.attackType: Number
{% endhint %}

This is a player’s attack type performed by pressing z. (default value: 0)

<table><thead><tr><th width="134">attackType</th><th>Description</th></tr></thead><tbody><tr><td>0</td><td>If the attackType is not set up, it means it is set to the default attack type.</td></tr></tbody></table>

**Example**

Change the avatar’s attackType.

```jsx
// Activates function when q is pressed 
// App.addOnKeyDown Description
App.addOnKeyDown(81, function (player) {
	player.attackType = 0;
	App.sayToAll(`attackType: ${player.attackType}`);
	player.sendUpdated();
});
```

### attackParam1

{% hint style="info" %}
&#x20;player.attackParam1: Number
{% endhint %}

This is an attribute for the attack image’s distance range shown when pressing z. The attack’s possible distance range does not increase.

**Example**

Change the attackParam1.

<div align="left"><figure><img src="https://3059601135-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MkvEvcz_LX5eDyvl13E%2Fuploads%2FfnC1zvWApQPgJOyRMqNE%2FattackParam.gif?alt=media&#x26;token=b4e18584-42ca-4fd6-889c-fde56115b699" alt=""><figcaption></figcaption></figure></div>

```jsx
// Activates function when q is pressed 
// App.addOnKeyDown Description
App.addOnKeyDown(81, function (player) {
	App.sayToAll(`attackType: ${player.attackType}`);
	App.sayToAll(`attackParam1: ${player.attackParam1}`);
	player.attackType = 0;
	player.attackParam1 = 10;
	player.sendUpdated();
});
```

### attackParam2

{% hint style="info" %}
player.attackParam2: Number
{% endhint %}

This is an attribute for distance available for attack. This is only valid when attackType is set to a ranged attack.

**Example**

Set a ranged attack using attackParam2.

![](https://3059601135-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MkvEvcz_LX5eDyvl13E%2Fuploads%2FZ597YL50kxoH7x3tw3Fz%2Fimage.png?alt=media\&token=c83fa8cd-8a1c-426e-9b21-88e08face733)

```jsx
// Activates function when q is pressed
// App.addOnKeyDown
App.addOnKeyDown(81, function (player) {
	player.attackType = 2;
	player.attackParam2 = 5;
	App.sayToAll(`attackType: ${player.attackType}`);
	App.sayToAll(`attackParam2: ${player.attackParam2}`);
	player.sendUpdated();
});
```

### attackSprite

{% hint style="info" %}
&#x20;player.attackSprite: ScriptDynamicResource
{% endhint %}

This is an attribute for the attack image shown when pressing z.

**Example**

Apply the boxing game’s glove attack image.

<div align="left"><figure><img src="https://3059601135-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MkvEvcz_LX5eDyvl13E%2Fuploads%2FhpLn1Jj32ziyKshODtHj%2FredBoxing.png?alt=media&#x26;token=c58e0677-c359-44d1-933d-a0f6c899df16" alt=""><figcaption></figcaption></figure></div>

<div align="left"><figure><img src="https://3059601135-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MkvEvcz_LX5eDyvl13E%2Fuploads%2FDYBTij5Brqpp9hzADBuE%2Fattack.gif?alt=media&#x26;token=79bb307d-a229-4e31-9d13-354b03fc800c" alt=""><figcaption></figcaption></figure></div>

```jsx
let redBoxing = App.loadSpritesheet("redBoxing.png");
// Activates function when q is pressed 
// App.addOnKeyDown Description
App.addOnKeyDown(81, function (player) {
	player.attackSprite = redBoxing;
	player.sendUpdated();
});
```

### walletAddress

{% hint style="info" %}
player.walletAddress: String
{% endhint %}

This is the player’s wallet address.

**Example**

Call the wallet address. If there is no wallet address, the results called will be **null**.

```jsx
// Activates function when q is pressed 
// **[App.addOnKeyDown Description (Link)](https://www.notion.so/Callbacks-7ac5078bab7c4f3180ae05463713581d)**
App.addOnKeyDown(81, function (player) {
	App.sayToAll(`${player.walletAddress}`)
});
```

### storage

{% hint style="info" %}
player.storage: String
{% endhint %}

This is the storage space for the player value within the space. (Limited to the Space)

**Example**

Store the data in player storage and check it.

{% hint style="success" %}
&#x20;Even after closing the app and restarting it, the stored values will not disappear.
{% endhint %}

```jsx
// Activates function when q is pressed 
// App.addOnKeyDown Description
App.addOnKeyDown(81,function(player){
	player.storage = "data";
	player.save(); // Applies the changed storage value to player.save() when storage values are changed
})

// Activates function when w is pressed 
App.addOnKeyDown(87,function(player){
	App.sayToAll(player.storage); // Displays the value saved in player storage on the chat screen
})
```

### isMobile

{% hint style="info" %}
&#x20;player.isMobile : Boolean
{% endhint %}

This displays whether the player is connected via mobile in true or false.

**Example**

Display mobile  PC status in the entry message when a player enters.

```jsx
// Activates function when a player enters
App.onJoinPlayer.Add(function(player){	
	if(player.isMobile){
		App.sayToAll(`${player.name} entered from mobile.`)	
	} else{
		App.sayToAll(`${player.name} entered from PC.`)
	}
});
```

####

### isMoving

{% hint style="info" %}
player.isMoving : Boolean
{% endhint %}

If the player is moving, this function returns True. If not, this returns False.

**Example**

Detect the player's movement and display a message.

```jsx
App.onUpdate.Add(function (dt) {
	let _players = App.players;
	for (let i in _players) {
		let p = _players[i];
		if (p.isMoving) {
			App.sayToAll(`${p.name} is moving...`);
		}
	}
});
```

####

### isJumping

{% hint style="info" %}
player.isJumping : Boolean
{% endhint %}

If the player is jumping, this function returns True. If not, this returns False.

**Example**

Detect the player's movement and display a message.

```jsx
App.onUpdate.Add(function (dt) {
	let _players = App.players;
	for (let i in _players) {
		let p = _players[i];
		if (p.isJumping) {
			App.sayToAll(`[System] ${p.name} is jumping...`);
		}
	}
});
```

####

### customData

{% hint style="info" %}
&#x20;player.customData : String
{% endhint %}

This field saves the value received as a query string.

**Example**

[**How to Use URL Query Strings**](https://docs.zep.us/zep-script/zep-script-guide/appendix/how-to-use-url-query-strings)

### displayRatio

{% hint style="info" %}
player.displayRatio
{% endhint %}

This function zooms the player's display in or out. (Default Value: 1)

**Example**

Create a key to zoom in or out.

```
// Activates function when Q is pressed
// Press once to zoom in and press again to zoom out
App.addOnKeyDown(81,function(player){
	if(player.displayRatio == 1){
		player.displayRatio = 5;
	}else{
		player.displayRatio = 1;
	}
	player.sendUpdated(); //* When the player's field value is updated, apply it as player.sendUpdated()
})
```

<div><figure><img src="https://3059601135-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MkvEvcz_LX5eDyvl13E%2Fuploads%2FuF0J91vjPmHp2l0AwpRk%2Fimage.png?alt=media&#x26;token=bd691c2b-3fa9-4222-b7bd-b8280dcdbe9d" alt=""><figcaption><p>displayRatio = 1</p></figcaption></figure> <figure><img src="https://3059601135-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MkvEvcz_LX5eDyvl13E%2Fuploads%2F2K95BINyMXRsq0XiUBcE%2Fimage.png?alt=media&#x26;token=3a2254bf-2b73-4c6c-a18e-5225e0034224" alt=""><figcaption><p>displayRatio = 5</p></figcaption></figure></div>

### titleColor

{% hint style="info" %}
player.titleColor
{% endhint %}

This function can read and change the player title's color.

You can enter enum values or hex code values.

```
Available Enum ColorType
{ WHITE, BLACK, RED, GREEN, BLUE, ORANGE, PURPLE, GRAY, YELLOW, MAGENTA, CYAN }
```

**Example**

Change the title color.

![](https://3059601135-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MkvEvcz_LX5eDyvl13E%2Fuploads%2FYUc2JkHzGr7jQd63Xpgo%2Fimage.png?alt=media\&token=37c10d93-05e6-43ea-bc53-b916e6e8a810)

```
// Activates function when Q is pressed
App.addOnKeyDown(81, function (player) {
	player.title = "🔸Title🔸";
	// When enum values are entered
	player.titleColor = ColorType.CYAN;
	
	// When hex codes are entered (Delete "//" when using the following)
	// player.titleColor = 0x00FFFF;
	
	player.sendUpdated(); //*When the player's field value is updated, apply it as player.sendUpdated()
});
```

### emailHash

{% hint style="info" %}
player.emailHash
{% endhint %}

This function reads the hash value of the player's email.

**Example**

Display the hash value of a player.

```javascript
// Activates function when a player enters 
App.onJoinPlayer.Add(function(player){
  App.sayToAll(`name: ${player.name} emailHash: ${player.emailHash}`);
})
```

### isGuest

{% hint style="info" %}
player.isGuest
{% endhint %}

If the player is not signed in, this function returns True.

**Example**

Show "GUEST" as a title when a guest who is not signed in enters.

```jsx
// Activates function when a player enters 
App.onJoinPlayer.Add(function(player){
  if(player.isGuest){
    player.title = "GUEST";
    player.sendUpdated();
  }
})
```
