User Tools

Site Tools


scripting

Client scripting

The client script must be present in the project folder/Scripts with the same filename as Hello.lua.

Client.width : Get the width of the screen.
Client.height : Get the vertical size of the screen.
Client.ShowAlert (text, callback) : Raises a notification message.
Client.ShowYesNoAlert (text, callback) : Prompts Yes / No message.
Client.ShowBuyItem (id, amount, callback) : Raises a message to purchase a specific item.
Client.Quit() : Close the client.

ScriptEventPublisher Client.GetTopic (topic) : Register a specific topic to send messages to the server. Client.FireEvent (topic, args …): Sends a message to the server with a specific topic.

Client.RunLater (callback, t) : Execute the callback function after t seconds.

Camera : the object that controls the camera
Point : a class containing x, y coordinates
Rect : a class containing a rectangle of x, y, width, height
Image : Class to output image
Text : Class to output the text
Slider : Class to output control controller
Button : Class to output the button
Panel : Class to output the panel
ScrollPanel : Class to display the scrolling panel
GridPanel : Class to output the panels that are arranged in Grid

Server scripting

The server script must be present in the project folder/ServerScripts with the same file name as Hello.lua.

Server.onJoinPlayer (unit) : A new user has connected.
Server.onLeavePlayer (unit) : A certain user has left the game.
Server.SendCenterLabel (text) : Displays the middle label.
Server.SendSay (text, color) : Display the message in the chat window.

ScriptEventPublisher Server.GetTopic (topic) : Register a specific topic to send messages to the client.
Server.FireEvent (topic, args …) : Send a message to the client with a specific topic.

Server.players : Get a list of users.
Server.fields : Get the entire map list.
Server.CreateEventUnit (name, imageID) : Creates an event unit.
Server.GetField (dataID) : Get the map of the specific ID.
ScriptUnit : This is an object such as a monster or a player.

unit.type = Unit type (0 = Player, 1 = Event, 2 = Monster)

Example) Server Script - Message when specific monster / user is killed File: Scripts / Servers / Hello.lua

- If the attacker is nil, it is suicide, otherwise it is kill.
function onUnitDead (target, attacker)
if target.type == 0 then - if player
Server.SendCenterLabel ('Player' .. target.name .. 'is dead.')
endif
end

Server.onUnitDead.Add (onUnitDead)

Example) Server Script - Player Level Up, Message Output File: Scripts / Servers / Hello.lua

function onUnitLevelUp (target, level)
Server.SendCenterLabel (target.name .. 'is' .. level .. '!')
end

Server.onUnitLevelUp.Add (onUnitLevelUp)
scripting.txt · Last modified: 2019/03/30 11:49 by 네코네코한민