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

GlobalEvents

onStartUp()

onStartup has no parameters, requires no return, and only runs once during the start of the server.

Example startup.lua

function onStartup()
    print("There are " ..#Game.getHouses().. " houses registered to this map")
end

You can register in data/globalevents/globalevents.xml by using type="startup" like so:

<globalevent type="startup" name="ServerStartup" script="startup.lua" />

onShutdown()

onShutdown has no parameters, requires no return, and only runs once during the shutdown of the server

Example shutdown.lua

function onShutdown()
    for index, player in pairs(Game.getPlayers()) do
        player:save()
    end
end

You can register in data/globalevents/globalevents.xml by using type="shutdown" like so:

onRecord(current, old)

onRecord has two parameters, requires return true, and runs each time a new record is made for most players online

  • current -- number value of new record, for most players online

  • old -- number value of old record, for most players online

Example record.lua

You can register in data/globalevents/globalevents.xml by using type="record" like so:

onTime()

onTime has one parameter which represents the time it executes, requires return true, and runs each each day at same time

Example ontime.lua

You can register in data/globalevents/globalevents.xml by giving it a unique name and setting the time using time="time" like so:

onThink()

onThink has one parameter which represents how often it executes in milliseconds, requires return true, and runs as often as specified in globalevents.xml

Example onthink.lua

You can register in data/globalevents/globalevents.xml by giving it a unique name and setting how often it will execute using interval="1000" time is in milliseconds

Last updated