Scripting
Script Structure
onStartup()Parameters:
None
Return Value:
true: Works as normal, no errors or prints to the console.
false: Prints "Failed to execute event".
Example:
function onStartup() print("Game server has started.") return true end
onShutdown()Parameters:
None
Return Value:
None
Example:
function onShutdown() for _, player in pairs(Game.getPlayers()) do -- Send FYI box, text messages won't go through before player is kicked player:popupFYI("Server is shutting down.") end end
onTime()Parameters:
time: Time defined in XML.
Return Value:
Follows same behavior as onStartup()
Example:
-- <globalevent time="12:00" script="this_script.lua" /> function onTime(time) print("Event is being executed at 12:00!") end
onThink(interval)Parameters:
interval: Millisecond "think" interval defined in XML.
Return Value:
Follows same behavior as onStartup()
Example:
function onThink(interval) for _, player in pairs(Game.getPlayers()) do player:sendTextMessage(MESSAGE_INFO_DESCR, "Your name is " .. player:getName()) end return true end
onRecord(current, old)Parameters:
current: New player count record.
old: Previous player count record.
Return Value:
Follows same behavior as onStartup()
Example:
function onRecord(current, old) Game.broadcastMessage("New player count record: " .. current) return true end
Last updated
Was this helpful?