Event Listeners
Introduction
These functions operate in response to specific situations that may happen in a ZEP Space such as players typing specified words or attacking a specific object.
Name | Description |
---|---|
onSay | Function that operates when a player types chat |
onPlayerTouched | Function that operates when avatars collide with each other |
onObjectTouched | Function that operates when an avatar collides with an object |
onAppObjectTouched | Function that operates when an avatar collides with an object with a key value |
onUnitAttacked | Function that operates when an avatar attacks another avatar with the Z key |
onObjectAttacked | Function that operates when an avatar attacks an object with the Z key |
onSidebarTouched | Function that operates when a player touches the Sidebar app |
onTriggerObject | Function that operates when an avatar interacts with an object with the F key |
onAppObjectAttacked | Function that operates when an avatar attacks an object with a key value with the Z key |
📚 API Description and Example
Event Listeners at a Glance
onSay
App.onSay.Add(function(player, text){});
This function operates when a player enters chat.
Parameters
Name | Type | Description |
---|---|---|
player | Player | The player’s parameter refers to the player who enters chat. The player’s parameter names can be changed arbitrarily. |
text | String | Text refers to the entered chat content. The text’s parameter names can be changed arbitrarily. |
Example
Hangul quiz - Makes a function to guess the answer via chat:
onPlayerTouched
App.onPlayerTouched.Add(function(sender, target, x, y){});
This function operates when an avatar collides with another avatar.
Parameters
Name | Type | Description |
---|---|---|
sender | Player | The player who collides |
target | String | The player who is the object of the collision |
x, y | Number | The X and Y coordinate of the location where the collision occurs |
The parameter name of sender, target, X, and Y can be changed arbitrarily |
Example
Display a message when two avatars collide.
onObjectTouched
App.onObjectTouched.Add(function(sender, x, y){});
This function operates when an avatar collides with an object.
Parameters
Name | Type | Description |
---|---|---|
sender | Player | The player who collides with the object |
x, y | Number | The X and Y coordinate of the location where the collision occurs |
tileID | Number | The tile ID of the object |
obj | Object | Object |
Example
Label display
⭐ A collision with an object without the overlap: true
attribute cannot call this function.
onAppObjectTouched
App.onAppObjectTouched.Add(function(key, sender, x, y){});
️This function operates when an avatar collides with an object with a key value.
Parameters
Name | Type | Description |
---|---|---|
key | String | The key value of the object |
sender | Player | The player who collides with the object |
x, y | Number | The X and Y coordinate of the location where the collision occurs |
Example
Label display
⭐ A collision with an object without the overlap: true
attribute cannot call this function.
onUnitAttacked
App.onUnitAttacked.Add(function(sender, x, y, target){});
This function operates when an avatar attacks another avatar with Z.
Parameters
Name | Type | Description |
---|---|---|
sender | Player | The player who attacks |
x, y | Number | The X and Y coordinate of the location of the player who attacks |
target | Player | The player who is under attack |
The parameter name of sender, target, x, and y can be changed arbitrarily |
Example
Display a message when a player attacks another player.
onObjectAttacked
App.onObjectAttacked.Add(function(sender, x, y){});
This function operates when an avatar attacks an object with the Z key.
Parameters
Name | Type | Description |
---|---|---|
sender | Player | The player who attacks |
x, y | Number | The X and Y coordinate of the location of the object |
The parameter name of sender, x, and y can be changed arbitrarily. |
Example
Display a message when an avatar attacks an object.
⭐ An attack on an object without the overlap: true
attribute cannot execute the function.
onSidebarTouched
App.onSidebarTouched.Add(function(player){});
This function operates when a player touches the Sidebar app.
Parameters
Name | Type | Description |
---|---|---|
player | Player | The player who touches the Sidebar app |
Example
Display a message on touching the Sidebar app.
Related Tutorial
onTriggerObject
App.onTriggerObject.Add(function(player, layerID, x, y){});
This function that when an avatar interacts with an object with the F key.
Parameters
Name | Type | Description |
---|---|---|
player | Player | The player who interacts with the object |
layerID | Number | The ID of the layer where the object is installed Object: layerID = 3 Top object: layerID = 5 |
x, y | Number | The X and Y coordinate of the location of the object |
Example
Display a message on interacting with the object.
onAppObjectAttacked
This function operates when an avatar attacks an object with a key value with the Z key.
Reference: Object npcProperty
Parameters
Name | Type | Description |
---|---|---|
sender | Player | The player who attacks |
x, y | Number | The X and Y coordinate of the location of the object |
layer | Number | The layer where the object is installed |
key | String | The key value of the object |
Example
Display a message on attacking an object with a key value.
⭐ Attacking an object without the collide: true
property does not execute the function.
Reference
Sidebar AppLast updated