For the complete documentation index, see llms.txt. This page is also available as Markdown.

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.

onJoinPlayer

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.

onLeavePlayer

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

spaceHashID & mapHashID

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.

playerCount

App.playerCount: Number

This calls the number of all players on the map where the app is installed.

cameraEffect & cameraEffectParam1

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

displayRatio

App.displayRatio

Value to control display zooming (Default value: 1)

storage

App.storage: String

App value storage space in the Space (Limited to Space)

followPlayer

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.

onPlayerTouched

App.onPlayerTouched.Add(function(sender, target, x, y){});

This function operates when an avatar collides with another avatar.

onObjectTouched

App.onObjectTouched.Add(function(sender, x, y){});

This function operates when an avatar collides with an object.

onAppObjectTouched

App.onAppObjectTouched.Add(function(key, sender, x, y){});

️This function operates when an avatar collides with an object with a key value.

onUnitAttacked

App.onUnitAttacked.Add(function(sender, x, y, target){});

This function operates when a player attacks another avatar with Z.

onObjectAttacked

App.onObjectAttacked.Add(function(sender, x, y){});

This function operates when a player attacks an object with the Z key.

onSidebarTouched

App.onSidebarTouched.Add(function(player){});

This function operates when a player touches the Sidebar app.

onTriggerObject

App.onTriggerObject.Add(function(player, layerID, x, y, key){});

This function that when an avatar interacts with an object with the F key.

onAppObjectAttacked

This function operates when an avatar attacks an object with a key value with the Z key.

☎️ Callbacks

runLater

App.runLater(function(){}, time: number);

This executes a callback function after a period of time (in seconds).

addOnTileTouched

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

App.addOnLocationTouched(name: string, function(player){})

This executes a callback function when a player gets to the designated area specified by the Map Editor.

addOnKeyDown

App.addOnKeyDown(keycode : number, function(player){});

This executes a callback when a player presses the specified key.

setTimeout

setTimeout(function(){}, time: number);

This executes a callback after time (ms).

setInterval

setInterval(function(){}, time: number);

This executes a callback at a specified time interval (ms).

addMobileButton

App.addMobileButton( anchor: number, posX: number, posY: number, function(player){} )

This executes by pressing a custom button added in the mobile environment.

putMobilePunch

App.putMobilePunch(enable: boolean = true)

This adds a punch button in the mobile environment when "enable" is "true."

putMobilePunchWithIcon

App.putMobilePunchWithIcon(icon: ScriptDynamicResource)

This function adds a punch button using a image loaded.

πŸ’  Methods

loadSpritesheet

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.

showCenterLabel

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.

showCustomLabel

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.

showWidget

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.

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.

hideBuyAlert

player.hideBuyAlert()

This function closes a player's purchase widget.

showYoutubeWidget

App.showYoutubeWidget(link: string, align: string, width: integer, height: integer): ScriptWidget

This function calls the YouTube video corresponding to the link to the widget.

spawnPlayer

App.spawnPlayer(playerID: string, tileX: integer, tileY: integer)

This function moves the player corresponding to playerID to tileX and tileY coordinates.

kickPlayer

App.kickPlayer(playerID: string)

This function kicks the player corresponding to playerID.

forceDestroy

App.forceDestroy();

This function shuts down the mini-game app.

clearChat

App.clearChat();

This function deletes all chat history.

getPlayerByID

App.getPlayerByID(playerID: string);

This function returns a player corresponding to the id.

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.

changeAttackSound

App.changeAttackSound(fileName:string)

This function changes the poke (Z key) sound effects.

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.

httpPostJson

App.httpPostJson(url: string, headers: object, body: object, function(res: string))

This function calls for HTTP Post request in JSON.

sendUpdated

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

width & height

Map.width : Number Map.height : Number

Calls the map’s width and height values.

πŸ’  Methods

putTileEffect

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?

putObjectMultiple

Map.putObjectMultiple(tileArray: array, type: PutObjectType, dynamicResource: ScriptDynamicResource, option: object);

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.

putObjectWithKey

Map.putObjectWithKey(x: number, y: number, dynamicResource: ScriptDynamicResource, option: JsValue)

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

getObjectWithKey

Map.getObjectWithKey(key: String)

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

playObjectAnimation

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.

playObjectAnimationWithKey

Map.playObjectAnimation(key: string, animName: string, repeatCount: number)

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

moveObject

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.

moveObjectWithKey

Map.moveObjectWithKey(key: string, targetX: number, targetY: number, path:boolean = true)

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

clearAllObjects()

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."

hasLocation

Map.hasLocation(locationName: String)

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

getObjectsByType

Map.getObjectsByType(type: numer) : array

This function returns the objects that correspond to Type.

getTopObjectsByType

Map.getTopObjectsByType(type: numer) : array

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

sayObjectWithKey

Map.sayObjectWithKey( key: string, message: string )

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

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

πŸ‘₯ 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

tileX, tileY

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.

disableVideo, disableAudio

player.disableVideo : Boolean player.disableAudio : Boolean

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

attackType

player.attackType : Number

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

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.

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.

attackSprite

player.attackSprite : ScriptDynamicResource

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

walletAddress

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.

customData

player.customData : String

This field saves the value received as a query string. How to Use URL Query Strings

displayRatio

player.displayRatio: number

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

titleColor

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

showCenterLabel

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.

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.

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.

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.

sendMessage

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

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

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.

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.

showAlert

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

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

showWidgetResponsive

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

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.

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

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.

getLocationName

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.

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.

spawnAtMap

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.

sendUpdated

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

sendMessage

widget.sendMessage(object: any)

This sends data to the widget from the App.

destroy

widget.destroy()

This function closes the widget.

Last updated

Was this helpful?