Methods

Introduction

The following functions provide general features that occur within ZEP such as UI, user control, sound, etc.

Convenient features such as displaying UI on a player’s personal screen, moving players, playing sounds exclusively for a player, etc. are provided below.

UI

Name
Description

showCenterLabel

Function to display a text for 3 seconds at a specific location to a player

showCustomLabel

Function to display a text for 3 seconds at a specific location to a player Text can be decorated by using span tags in the text part.

showWidget

Function to call a widget to a specific location to a player

showBuyAlert

Function to display a purchase widget to a player and execute a callback function that runs when a purchase is completed

hideBuyAlert

Function to hide a player's purchase widget

sendMessage

Function to send a private message to a player in the chat window

showPrompt

Function to display an input window and execute a callback function that runs according to a player's response.

showConfirm

Function to display an confirm window and execute a callback function that runs when a player clicks "OK".

showAlert

Function to display an alert window and execute a callback function that runs when a player clicks "OK".

showWidgetResponsive

Function to display the widget by defining the top/bottom/left/right margin in percentage to the screen size.

openWebLink

Function to open a web URL in a new tab or window to a player

showEmbed

Function to open a web URL as an embed. Size and location are adjustable.

Data Load

Name
Description

isEmail

Function to compare the player’s email

getLocationName

Displays the name of the specific location of where the player is standing

User Control

Name
Description

spawnAt

Function to move the player’s avatar to a designated coordinate

spawnAtLocation

Function to move the player’s avatar to a designated location

spawnAtMap

Function to move a player to another Space or to another map

Sound

Name
Description

playSound

Function to play a sound file to a player

playSoundLink

Function to play the sound URL to a player

Common

Name
Description

sendUpdated

Function to apply the changed value whenever changes are made to any of the field values pertaining to Player

save

Function to apply the changed values to whenever changes are made to any Player storage values

📚 API Explanation and Example

🎨 UI Methods

UI at a Glance

showCenterLabel

player.showCenterLabel(text: string, color: uint = 0xFFFFFF, bgColor: uint = 0x000000, offset: int = 0, time: number = 3000)

This function displays text for 3 seconds at a designated location to the corresponding player.

Parameters

Name
Type
Description

text

String

Text to display on label

color

Unit

Color of text to be displayed (HexCode) If left blank, it is set to white (0xFFFFFF). ➡️Color Picker

bgColor

Unit

Background color of the message to be displayed as the label If left blank, it is set to black (0xFFFFFF).

offset

Integer

The higher the offset value, the location will be closer to the bottom. If left blank, 0 is the designated value.

time

number

Label display time (ms), default 3000 ms (3 seconds)

Example

Display the label as yellow.

showCustomLabel

player.showCustomLabel(text: string, color: number = 0xFFFFFF, bgColor: number = 0x000000, offset: number = 0, width = 100, opacity = 0.6, time: number = 3000);

This function displays a text for 3 seconds at a specific location to all players.

You can decorate the text by adding span tags to the text.

Parameters

Name
Type
Description

text

String

Text to display on label (allows span tags)

color

Unit

Color of text to be displayed (HexCode) If left blank, it is set to white (0xFFFFFF). ➡️Color Picker

bgColor

Unit

The background color of the message to be displayed as the label If left blank, it is set to black (0xFFFFFF).

offset

number

The higher the offset value, the location will be closer to the bottom. If left blank, 0 is the designated value.

width

number

A value that sets the label's width to n% (default 100)

opacity

number

A value that sets the label background's transparency (default 0.6, range 0 to 1)

time

number

Label display time (ms), default 3000 ms (3 seconds)

Example

Decorate the label using HTML tags.

showWidget

player.showWidget(fileName: string, align: string, width: integer, height: integer): ScriptWidget

This function calls the html file as a widget to the player’s designated align location.

Parameters

Name
Type
Description

fileName

String

Name of the file being called

align

String

Location to display widget ’popup’, ‘sidebar’, ‘top’, ‘topleft’, ‘topright’, ‘middle’, ‘middleleft’, ‘middleright’, ‘bottom’, ‘bottomleft’, ‘bottomright’

width height

Integer

Width and height size area to display the widget (px)

Example

Replicate the Korean consonant quiz widget.

showBuyAlert

player.showBuyAlert(itemName: string, price: number, callback: function)

This function displays a purchase widget to a player and executes a callback function that runs when a purchase is completed.

The consumed ZEM will be sent to the creators and the history can be found in the My Donation History page.

Please refer to the Settlement Guide for more detailed information on ZEP settlement.

Parameters

Name
Type
Description

itemName

String

Name of the item to display in the purchase widget

price

Number

Price of the item (Currency: ZEM)

callback

Function

Callback functions to execute when a purchase is completed

payToSpaceOwner

Boolean

When false: the revenue goes to the app owner

When true: the revenue goes to the map owner

(Default value: false)

option

Object

You can set the following options. message : Sets the text to be displayed in the purchase widget. timer : You can set the time (ms) for displaying the purchase widget.

Example

Purchase an item and save data in player.storage.

Purchase Menu
When 'timer' and 'message' Options Were Set Up

hideBuyAlert

player.hideBuyAlert()

This function closes a player's purchase widget.

Parameter

None

sendMessage

player.sendMessage(text: string, color: uint = 0xFFFFFF)

This function sends a private message to a player in the chat window.

Parameters

Name
Type
Description

text

String

Text to display on label

color

Uint

Color of text to be displayed (HexCode) If left blank, it is set to white (0xFFFFFF). ➡️Color Picker

Example

Display a welcome message that is only shown to the designated player.

showPrompt

player.showPrompt(text: string, function(inputText))

This function displays an input window and executes a callback function that runs according to a player's response.

Parameters

Name
Type
Description

text

String

Text to display on the input window

inputText

String

Text a player entered

Example

Create an input window that shows a "correct" message when entering "1234".

showConfirm

player.showConfirm(text: string, function(result))

This function displays an confirm window and executes a callback function that runs when a player clicks "OK". When a player clicks "Cancel," this callback function doesn't operate.

Parameters

Name
Type
Description

text

String

Text to display on the confirm window

result

Boolean

When a player clicks "OK", true

Example

Display a text to the chat window when "OK" is clicked.

showAlert

player.showAlert(text: string, function())

This function displays an alert window and executes a callback function that runs when a player clicks "OK".

Parameter

Name
Type
Description

text

String

Text to display on the alert window

Example

Display a text to the chat window when "OK" is clicked.

showWidgetResponsive

This function displays the widget by defining the top/bottom/left/right margin using a responsive percentage of the screen size.

Parameters

Name
Type
Description

fileName

String

Name of the file to call

margin top/left/right/bottom

String

Top/bottom/left/right margin as a percentage

Example

Check how the widget size changes when scaling the screen size.

16KB
Open

This function opens a web URL in a new tab or window to a player.

Parameters

Name
Type
Description

url

String

URL adress to open

popup

boolean

When true: the URL opens as a new window

Example

Open a web URL in a new windwow.

Web Page in a New Window

showEmbed

player.showEmbed(url: string, align: string, width: number, height: number, hasBackdrop: boolean = true)

This function opens a web URL as an embed in the designated location.

Parameters

Name
Tyoe
Description

url

String

URL adress to open

align

String

Embedding area ‘sidebar’, ‘top’, ‘topleft’, ‘topright’, ‘middle’, ‘middleleft’, ‘middleright’, ‘bottom’, ‘bottomleft’, ‘bottomright’

width height

number

Width and hight size of the embedding area (px)

hasBackdrop

boolean

When true: shadows appear on the outline of the embedding area

Example

Display a web URL as an embed

💻 Data Load Methods

Data Load Methods at a Glance

isEmail

player.isEmail(email: string): boolean

Depending on whether the corresponding player’s email is the same as the parameter value, the value will return as true when it matches and false when it does not match.

Parameter

Name
Type
Description

email

String

Email text that will be used for comparison

Example

Compare the player’s email to the specified text.

getLocationName

player.getLocationName : string

This displays the location name of where the player is standing.

Specific areas can be set up on the Map Editor > Tile Effects menu.

Parameter

  • None

Example

Display the area name of the tile the avatar is standing on.

→ If there is no specified area set, it will be displayed as an empty space.

🙍‍♂️ User Control

User Control at a Glance

spawnAt

player.spawnAt(tileX: int ,tileY: int, dir: int = 0)

This moves the player’s avatar to look in the designated direction when on tileX and tileY coordinates.

Parameters

Name
Type
Description

tileX tileY

Integer

The x and y coordinates values of where the player will be moved to

dir

Integer

Direction the avatar will look at • Left: 1 • Up: 2 • Right: 3 • Down: 4 • Top-Left: 5 • Bottom-Left: 6 • Top-Right: 7 • Bottom-Right: 8

Example

Move the players that enter to the designated coordinates.

spawnAtLocation

player.spawnAtLocation(name: string, dir:int = 0)

This moves the player’s avatar to a specific area called name and makes them look in a designated direction.

Parameters

Name
Type
Description

name

String

Name of the specific are the player will be moved to

dir

Integer

Direction the avatar will look at • Left: 1 • Up: 2 • Right: 3 • Down: 4 • Top-Left: 5 • Bottom-Left: 6 • Top-Right: 7 • Bottom-Right: 8

Example

Move the players that enter to a specific area.

spawnAtMap

player.spawnAtMap(spaceHashID string, mapHashID:string = null)

This moves the player to the corresponding Space’s map.

Parameters

Name
Type
Description

spaceHashID

String

spaceHashID of the Space the player will be moved to

mapHashID

String

If the mapHashID is not mentioned, by default the player will be moved to the “Entry Map” of the corresponding Space.

Example

Move the players that enter the map to the ZEP Tutorial Map. (Understanding Spaces and Maps)

🔉 Sound Methods

Sound Methods at a Glance

playSound

player.playSound(fileName: string, loop: boolean = false, overlap: boolean = false)

This function plays sound to the corresponding player.

Parameters

Name
Type
Description

fileName

String

Name of the file being called

loop

boolean

true: repeatedly play on a loop false: play one time

overlap

boolean

Whether sound overlap is available

Example

Set up a sound to play upon entry (file).

20KB
Open

player.playSoundLink(link: string, loop: boolean = false)

This function plays a sound for all players.

Parameters

Name
Type
Description

link

String

Sound url

loop

boolean

true: repeatedly play on a loop false: play one time

Example

Set up a sound to play upon entry (sound url).

💠 Common Methods

Common Methods at a Glance

sendUpdated

player.sendUpdated()

This function applies the changed value whenever field values pertaining to App or Player are changed.

Parameter

  • None

save

player.save()

This function applies the changed value whenever values pertaining to App or Player storage are changed.

Parameter

  • None

Last updated

Was this helpful?