Posts: 23
Threads: 7
Joined: Oct 2016
Thanks: 6
Given 1 thank(s) in 1 post(s)
10-19-2016, 10:49 PM
(This post was last modified: 10-29-2016, 09:15 AM by denwo.)
Hi everyone,i learned the cuberite api and lua but i still don't know how to make a timer?
for example i have a timer set to 1 sec to spawn mob every 1 sec and / or create a timer that executes every 5 seconds for 5 times and then it stops the timer.
Posts: 23
Threads: 7
Joined: Oct 2016
Thanks: 6
Given 1 thank(s) in 1 post(s)
Where should i put this? in Initialize?
also how would i get the current world?
Posts: 6,485
Threads: 176
Joined: Jan 2012
Thanks: 131
Given 1074 thank(s) in 852 post(s)
You should put it wherever you want the task to be started - if it is by a reaction to a player command, then the player command handler is the right place. If it should be done, say, if a player is killed, then the HOOK_KILLED is the right place.
As for the current world, "current for whom?" Each player has a world assigned to them, accessible via cPlayer:GetWorld(). Similarly, entities have a cEntity:GetWorld().