onThink has one parameter which represents how often it executes in milliseconds, requires return true, and runs as often as specified in globalevents.xml
Exampleonthink.lua
1
functiononThink(interval)
2
for index, player inpairs(Game.getPlayers())do
3
player:save()
4
end
5
returntrue
6
end
Copied!
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