ZEP Guidebook (EN)
Search…
⌃K

API Summary

🔍
Use Ctrl + F to search the API you want and click the title for details!

═════════════════════

🕹️ ScriptApp

═════════════════════

♻️ Lifecycle

onInit

App.onInit.Add(function(){})
This function is called once when running the app for the first time.
App.onJoinPlayer.Add(function(player){})
Once onInit is called, this event lets all connected players enter and then operates whenever a new player enters afterward.

onStart

App.onStart.Add(function(){})
This function is called once after players have entered via onJoinPlayer.

onUpdate

App.onUpdate.Add(function(dt){})
This function runs periodically about every 20ms.
App.onLeavePlayer.Add(function(player){})
This function operates whenever a player exits. After that, this function kicks all players from the app when another app is launched or the installed Game Block is destroyed.

onDestroy

App.onDestroy.Add(function(){})
It operates when another app is launched or the installed Game Block is destroyed.

🗃️ Field

App.spaceHashID: String App.mapHashID: String
This calls spaceHashID and mapHashID of the Space where an app is installed. (Understanding Spaces and Maps)

creatorID

App.creatorID
This calls the ID value of the player who executed the app.

players

App.players: ScriptPlayer[]
This calls a list of all players on the map as an array.
App.playerCount: Number
This calls the number of all players on the map where the app is installed.
App.cameraEffect: NONE = 0, SPOTLIGHT = 1 App.cameraEffectParam1: Number
App.cameraEffect: variable value to set the type of camera effect
App.cameraEffectParam1: range value of camera effect
App.displayRatio
Value to control display zooming (Default value: 1)

storage

App.storage: String
App value storage space in the Space (Limited to Space)
App.followPlayer: Boolean
This shows whether the app’s follow function is enabled. (Default value: false)

showName

App.showName: Boolean
This shows whether the player's nickname is hidden. (Default value: true)

🛰️ EventListeners

onSay

App.onSay.Add(function(player, text){});
This function operates when a player enters chat.
App.onPlayerTouched.Add(function(sender, target, x, y){});
This function operates when an avatar collides with another avatar.
App.onObjectTouched.Add(function(sender, x, y){});
This function operates when an avatar collides with an object.
App.onAppObjectTouched.Add(function(key, sender, x, y){});
️This function operates when an avatar collides with an object with a key value.
App.onUnitAttacked.Add(function(sender, x, y, target){});
This function operates when a player attacks another avatar with Z.
App.onObjectAttacked.Add(function(sender, x, y){});
This function operates when a player attacks an object with the Z key.
App.onSidebarTouched.Add(function(player){});
This function operates when a player touches the Sidebar app.
App.onTriggerObject.Add(function(player, layerID, x, y){});
This function that when an avatar interacts with an object with the F key.

☎️ Callbacks

runLater

App.runLater(function(){}, time: number);
This executes a callback function after a period of time (in seconds).
App.addOnTileTouched(x: integer, y: integer, function(player){})
This executes a callback function when a player gets to the designated X and Y coordinates.
addOnLocationTouched(name: string, function(player){})
This executes a callback function when a player gets to the designated area specified by the Map Editor.
App.addOnKeyDown(keycode : number, function(player){});
This executes a callback when a player presses the specified key.
setTimeout(function(){}, time: number);
This executes a callback after time (ms).
setInterval(function(){}, time: number);
This executes a callback at a specified time interval (ms).
App.addMobileButton( anchor: number, posX: number, posY: number, function(player){} )
This executes by pressing a custom button added in the mobile environment.
App.putMobilePunch(enable: boolean = true)
This adds a punch button in the mobile environment when "enable" is "true."

💠 Methods

App.loadSpritesheet(fileName: string, frameWidth: integer, frameHeight: integer, anims: array, frameRate: integer): ScriptDynamicResource
This function reads a sprite sheet picture file and makes it an object.
App.showCenterLabel(text: string, color: uint = 0xFFFFFF, bgColor: uint = 0x000000, offset: number = 0, time: number = 3000)
This function displays text for 3 seconds at the designated location for all players.
App.showCustomLabel(text: string, color: number = 0xFFFFFF, bgColor: number = 0x000000, offset: number = 0, width = 100, opacity = 0.6, time: number = 3000);
This function displays text for 3 seconds at the designated location for all players.
You can decorate the text by inserting span tags in the text part.

sayToAll

App.sayToAll(text: string, color: uint = 0xFFFFFF)
This function displays text in the chat window.
App.showWidget(fileName: string, align: string, width: integer, height: integer): ScriptWidget
This function loads the HTML file as a widget at the align position specified for all players.
App.showYoutubeWidget(link: string, align: string, width: integer, height: integer): ScriptWidget
This function calls the YouTube video corresponding to the link to the widget.
App.spawnPlayer(playeID: string, tileX: integer, tileY: integer)
This function moves the player corresponding to playerID to tileX and tileY coordinates.
App.kickPlayer(playerID: string)
This function kicks the player corresponding to playerID.
App.forceDestroy();
This function shuts down the mini-game app.

clearChat

App.clearChat();
This function deletes all chat history.

playSound

App.playSound(fileName: string, loop: boolean = false, overlap: boolean = false)
This function plays the sound file to all players.
App.playSoundLink(link: string, loop: boolean = false)
This function plays the sound corresponding to the link to all players.

stopSound

App.stopSound();
This function stops all playing sounds.

httpGet

App.httpGet(url: string, headers: object, function(res: string){})
This function calls for HTTP Get request.

httpPost

App.httpPost(url: string, headers: object, body: object, function(res: string))
This function calls for HTTP Post request.
App.httpPostJson(url: string, headers: object, body: object, function(res: string))
This function calls for HTTP Post request in JSON.
App.sendUpdated()
This function applies the updated app-related field values when changes are made.

save

App.save()
This function applies the updated app storage values when changes are made.

═════════════════════

🗺️ ScriptMap

═════════════════════

🗃️ Field

Map.width : Number Map.height : Number
Calls the map’s width and height values.

💠 Methods

Map.putTileEffect(x: number, y: number, tileID: TileEffectType)
This function applies a tile effect to the specified coordinates.

putObject

Map.putObject(x: number, y: number, dynamicResource: ScriptDynamicResource, option: JsValue)
This function places the object at the specified coordinates. (Reference coordinates: Left-Top) → What are Reference Coordinates?
Map.putObjectWithKey(x: number, y: number, dynamicResource: ScriptDynamicResource, option: JsValue)
This function places an object on the specified coordinates (Reference coordinates: Left-Top)
Map.getObjectWithKey(key: String)
This function gets the information of the object with the corresponding key value.
Map.playObjectAnimation(x: number, y: number, name: string)
This function activates the object animation at the corresponding coordinates.
The above function must be preceded by the Map.putObject function.
Map.playObjectAnimation(key: string, animName: string, repeatCount: number)
This function executes the object's sprite animation whose key value matches.
Map.moveObject(x: number, y: number, targetX: number, targetY: number, time: number)
This function moves the object from the object’s x,y coordinates to the target x,y coordinates for a certain amount of time (secs).
The above function must be preceded by the Map.putObject function.
Map.moveObjectWithKey(key: string, targetX: number, targetY: number, path:boolean = true)
This function moves an object with a key value to the specified coordinates.
Map.clearAllObjects()
This function removes all objects created by the ZEP script.

getTile

Map.getTile(layer: number, x: number, y: number)
This returns the type value of the tile at the x and y coordinates of the corresponding layer. If no tile, this returns "-1."
Map.hasLocation(locationName: String)
This function checks if the corresponding location exists in the map and returns true or false accordingly.
Map.getObjectsByType(type: numer) : array
This function returns the objects that correspond to Type.
Map.getTopObjectsByType(type: numer) : array
This function returns the top objects that correspond to each type.

═════════════════════

👥 ScriptPlayer

═════════════════════

🗃️ Field

id , name

player.id : Number player.name : String
This calls the player ID and nickname values.

title

player.title : String
Title is a yellow text that displays above the avatar’s nickname.

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.
Guest
-1
Staff
2000
Member
0
Admin
3000
Editor
1000
Owner
3001
player.tileX: Number player.tileY: Number
The x axis value and y axis value of where the player’s avatar is standing.

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.
Direction
Number
Direction
Number
Left
1
Top-Left
5
Up
2
Bottom-Left
6
Right
3
Top-Right
7
Down
4
Bottom-Right
8

moveSpeed

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

sprite

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

tag

player.tag: Any
Give necessary attribute values to a player by using tag.

hidden

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

spotlight

player.spotlight: Boolean
This activates or deactivates the player’s spotlight feature.
player.disableVideo : Boolean player.disableAudio : Boolean
This activates or deactivates the player’s video/audio features.
player.attackType : Number
This is a player’s attack type performed by pressing z. (Default value: 0)
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.
player.attackParam2: Number
This is an attribute for distance available for attack. This is only valid when attackType is set to a ranged attack.
player.attackSprite : ScriptDynamicResource
This is an attribute for the attack image shown when pressing z.
player.walletAddress : String
This is the player’s wallet address.

storage

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

isMobile

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

isMoving

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

isJumping

player.isJumping : Boolean
If the player is jumping, this function returns True. If not, this returns False.
player.customData : String
This field saves the value received as a query string. How to Use URL Query Strings
player.displayRatio: number
This function zooms the player's display in or out. (Default Value: 1)
player.titleColor: number
This function can read and change the player title's color.

emailHash

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

isGuest

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

💠 Methods

player.showCenterLabel(text: string, color: uint = 0xFFFFFF, bgColor: uint = 0x000000, offset: number = 0, time: number = 3000)
This function displays text for 3 seconds at a designated location to the corresponding player.
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.
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.
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.
player.sendMessage(text: string, color: uint = 0xFFFFFF)
This function sends a private message to a player in the chat window.
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.
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.

showAlert

player.showAlert(text: string, function())
This function displays an alert window and executes a callback function that runs when a player clicks "OK".
player.showWidgetResponsive(fileName:string, marginTop:number, marginRight:number, marginBottom:number, marginLeft:number)
This function displays the widget by defining the top/bottom/left/right margin using a responsive percentage of the screen size.

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.
player.getLocationName : string
This displays the location name of where the player is standing.

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.
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.
player.spawnAtMap(spaceHashID string, mapHashID:string = null)
This moves the player to the corresponding Space’s map.

playSound

Player.playSound(fileName: string, loop: boolean = false, overlap: boolean = false)
This function plays sound to the corresponding player.
player.playSoundLink(link: string, loop: boolean = false)
This function plays sound for all players.
player.sendUpdated()
This function applies the changed value whenever field values pertaining to App or Player are changed.

save

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

═════════════════════

🧙‍♂️ ScriptWidget

═════════════════════

🗃️ Field

id

widget.id
This calls the widget’s id value.

🛰️ EventListeners

onMessage

widget.onMessage.Add(function(player, data: any){});
Callback function that activates when a message is sent from the widget to the App.

💠 Methods

widget.sendMessage(object: any)
This sends data to the widget from the App.

destroy

widget.destroy()
This function closes the widget.