API Summary

πŸ”Use Ctrl + F to search the API you want and click the title for details!

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

πŸ•ΉοΈ ScriptApp

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

♻️ Lifecycle

circle-info

App.onInit.Add(function(){})

This function is called once when running the app for the first time.

circle-info

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.

circle-info

App.onStart.Add(function(){})

This function is called once after players have entered via onJoinPlayer.

circle-info

App.onUpdate.Add(function(dt){})

This function runs periodically about every 20ms.

circle-info

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.

circle-info

App.onDestroy.Add(function(){})

It operates when another app is launched or the installed Game Block is destroyed.

πŸ—ƒοΈ Field

spaceHashID & mapHashID

circle-info

App.spaceHashID: String App.mapHashID: String

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

circle-info

App.creatorID

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

circle-info

App.players: ScriptPlayer[]

This calls a list of all players on the map as an array.

circle-info

App.playerCount: Number

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

circle-info

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

circle-info

App.displayRatio

Value to control display zooming (Default value: 1)

storage

circle-info

App.storage: String

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

circle-info

App.followPlayer: Boolean

This shows whether the app’s follow function is enabled. (Default value: false)

showName

circle-info

App.showName: Boolean

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

πŸ›°οΈ EventListeners

circle-info

App.onSay.Add(function(player, text){});

This function operates when a player enters chat.

circle-info

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

This function operates when an avatar collides with another avatar.

circle-info

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

This function operates when an avatar collides with an object.

circle-info

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

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

circle-info

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

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

circle-info

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

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

circle-info

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

This function operates when a player touches the Sidebar app.

circle-info

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

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

circle-info

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

☎️ Callbacks

circle-info

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

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

circle-info

App.addOnTileTouched(x: integer, y: integer, function(player){})

This executes a callback function when a player gets to the designated X and Y coordinates.

circle-info

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

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

circle-info

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

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

circle-info

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

This executes a callback after time (ms).

circle-info

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

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

circle-info

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

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

circle-info

App.putMobilePunch(enable: boolean = true)

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

circle-info

App.putMobilePunchWithIcon(icon: ScriptDynamicResource)

This function adds a punch button using a image loaded.

πŸ’  Methods

circle-info

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.

circle-info

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.

circle-info

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.

circle-info

App.sayToAll(text: string, color: uint = 0xFFFFFF)

This function displays text in the chat window.

circle-info

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.

circle-info

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.

circle-info

player.hideBuyAlert()

This function closes a player's purchase widget.

circle-info

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

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

circle-info

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

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

circle-info

App.kickPlayer(playerID: string)

This function kicks the player corresponding to playerID.

circle-info

App.forceDestroy();

This function shuts down the mini-game app.

circle-info

App.clearChat();

This function deletes all chat history.

circle-info

App.getPlayerByID(playerID: string);

This function returns a player corresponding to the id.

circle-info

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

This function plays the sound file to all players.

circle-info

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

This function plays the sound corresponding to the link to all players.

circle-info

App.stopSound();

This function stops all playing sounds.

circle-info

App.changeAttackSound(fileName:string)

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

circle-info

App.httpGet(url: string, headers: object, function(res: string){})

This function calls for HTTP Get request.

circle-info

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

This function calls for HTTP Post request.

circle-info

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

This function calls for HTTP Post request in JSON.

circle-info

App.sendUpdated()

This function applies the updated app-related field values when changes are made.

circle-info

App.save()

This function applies the updated app storage values when changes are made.

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

πŸ—ΊοΈ ScriptMap

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

πŸ—ƒοΈ Field

circle-info

Map.width : Number Map.height : Number

Calls the map’s width and height values.

πŸ’  Methods

circle-info

Map.putTileEffect(x: number, y: number, tileID: TileEffectType)

This function applies a tile effect to the specified coordinates.

circle-info

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?arrow-up-right

circle-info

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.

circle-info

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

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

circle-info

Map.getObjectWithKey(key: String)

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

circle-info

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.

circle-info

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

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

circle-info

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.

circle-info

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

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

circle-info

Map.clearAllObjects()

This function removes all objects created by the ZEP script.

circle-info

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

circle-info

Map.hasLocation(locationName: String)

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

circle-info

Map.getObjectsByType(type: numer) : array

This function returns the objects that correspond to Type.

circle-info

Map.getTopObjectsByType(type: numer) : array

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

circle-info

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

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

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

πŸ‘₯ ScriptPlayer

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

πŸ—ƒοΈ Field

circle-info

player.id : Number player.name : String

This calls the player ID and nickname values.

circle-info

player.title : String

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

circle-info

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

circle-info

player.tileX: Number player.tileY: Number

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

circle-info

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

circle-info

player.moveSpeed : Number

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

circle-info

player.sprite : ScriptDynamicResource

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

circle-info

player.tag: Any

Give necessary attribute values to a player by using tag.

circle-info

player.hidden: Boolean

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

circle-info

player.spotlight: Boolean

This activates or deactivates the player’s spotlight feature.

circle-info

player.disableVideo : Boolean player.disableAudio : Boolean

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

circle-info

player.attackType : Number

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

circle-info

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.

circle-info

player.attackParam2: Number

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

circle-info

player.attackSprite : ScriptDynamicResource

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

circle-info

player.walletAddress : String

This is the player’s wallet address.

circle-info

player.storage : String

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

circle-info

player.isMobile : Boolean

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

circle-info

player.isMoving : Boolean

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

circle-info

player.isJumping : Boolean

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

circle-info

player.customData : String

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

circle-info

player.displayRatio: number

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

circle-info

player.titleColor: number

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

circle-info

player.emailHash

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

circle-info

player.isGuest

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

πŸ’  Methods

showCenterLabel

circle-info

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

circle-info

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

circle-info

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.

circle-info

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.

circle-info

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

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

circle-info

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.

circle-info

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.

circle-info

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

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

circle-info

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

circle-info

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.

circle-info

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

isEmail

circle-info

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

circle-info

player.getLocationName : string

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

spawnAt

circle-info

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

circle-info

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

circle-info

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

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

playSound

circle-info

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

This function plays sound to the corresponding player.

circle-info

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

This function plays sound for all players.

sendUpdated

circle-info

player.sendUpdated()

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

save

circle-info

player.save()

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

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

πŸ§™β€β™‚οΈ ScriptWidget

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

πŸ—ƒοΈ Field

id

circle-info

widget.id

This calls the widget’s id value.

πŸ›°οΈ EventListeners

onMessage

circle-info

widget.onMessage.Add(function(player, data: any){});

Callback function that activates when a message is sent from the widget to the App.

πŸ’  Methods

sendMessage

circle-info

widget.sendMessage(object: any)

This sends data to the widget from the App.

destroy

circle-info

widget.destroy()

This function closes the widget.

Last updated

Was this helpful?