Field

Introduction

These are the attribute values pertaining to players.

The player’s nickname (name), location (tileX / tileY), etc. can be viewed. The player’s spotlight (spotlight) feature and hide (hidden) feature can be activated. The player’s movement speed (moveSpeed) and image (sprite) can be adjusted. It’s also possible to utilize the Space's storage (storage) for storing player values.

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

NameDescription

🔒 id

Player ID value

name

Player Nickname value

title

Text to be displayed in yellow above an avatar’s nickname

🔒 role

A numerical value that represents a player’s permissions

🔒 tileX / tileY

The X and Y coordinate values where the avatar is standing

🔒 dir

A value representing the direction a player is looking

moveSpeed

A value representing the player’s movement speed

sprite

An avatar’s sprite image value

tag

Value storage space to assign required attribute values

hidden

If the value is set to true, the player is invisible

spotlight

Toggle player spotlight

🔒 disableVideo

Toggle player video

🔒 disableAudio

Toggle player audio

attackType

Player’s attack type when z is pressed

attackSprite

Player’s attack image value when z is pressed

attackParam1

Distance value that affects how far the attack image flies

attackParam2

Distance value available for attack Only valid when attackType is set to 2 (ranged attack)

🔒 walletAddress

The player’s wallet address value

storage

Storage space for player values in the Space (limited to the Space)

🔒 isMobile

Whether the player is connected via mobile

🔒 isMoving

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

🔒 isJumping

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

customData

Can read the URL query string and save the value

displayRatio

Zoom in or out player's display

titleColor

Player's title color

🔒 emailHash

The hash value of the player's email

🔒 isGuest

If the player is not signed in, returns True.

📚 API Description and Examples

id , name

player.id: Number player.name: String

Calls the player ID and nickname values.

Example

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

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

title

player.title: String

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

Example

Set up a title for a player when they enter.

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

role

player.role: Number

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

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

RoleNumberRoleNumber

Guest

-1

Staff

2000

Member

0

Admin

3000

Editor

1000

Owner

3001

Example

Display the permission role value in the chat screen.

// 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

player.tileX: Number player.tileY: Number

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.

// 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

player.dir: Number

The direction the player’s avatar is looking.

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

DirectionNumberDirectionNumber

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.

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

moveSpeed

player.moveSpeed: Number

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.

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

sprite

player.sprite: ScriptDynamicResource

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

Check the Understanding Sprite Sheets page if it’s your first time hearing about sprite images.

Example

Apply the Paintman-Blueman image as the avatar image.

// 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

player.tag: Any

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.

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

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

hidden

player.hidden: Boolean

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

The avatar in a hidden state is not visible, but it is possible to connect the video and audio.

Example

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

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

spotlight

player.spotlight: Boolean

This activates or deactivates the player’s spotlight feature.

Example

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

// 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

player.disableVideo: Boolean player.disableAudio: Boolean

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.

// 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

player.attackType: Number

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

attackTypeDescription

0

If the attackType is not set up, it means it is set to the default attack type.

Example

Change the avatar’s attackType.

// 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

player.attackParam1: Number

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.

// 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

player.attackParam2: Number

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.

// 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

player.attackSprite: ScriptDynamicResource

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

Example

Apply the boxing game’s glove attack image.

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

player.walletAddress: String

This is the player’s wallet address.

Example

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

// 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

player.storage: String

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.

Even after closing the app and restarting it, the stored values will not disappear.

// 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

player.isMobile : Boolean

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.

// 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

player.isMoving : Boolean

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

Example

Detect the player's movement and display a message.

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

player.isJumping : Boolean

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

Example

Detect the player's movement and display a message.

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

player.customData : String

This field saves the value received as a query string.

Example

How to Use URL Query Strings

displayRatio

player.displayRatio

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()
})

titleColor

player.titleColor

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.

// 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

player.emailHash

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

Example

Display the hash value of a player.

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

isGuest

player.isGuest

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.

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

Last updated