aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--builtin/builtin.lua26
-rw-r--r--doc/lua_api.txt3
2 files changed, 15 insertions, 14 deletions
diff --git a/builtin/builtin.lua b/builtin/builtin.lua
index 4c74b1c5f..c09697045 100644
--- a/builtin/builtin.lua
+++ b/builtin/builtin.lua
@@ -802,21 +802,21 @@ minetest.registered_on_respawnplayers, minetest.register_on_respawnplayer = make
minetest.timers_to_add = {}
minetest.timers = {}
minetest.register_globalstep(function(dtime)
- for indes, timer in ipairs(minetest.timers_to_add) do
- table.insert(minetest.timers, timer)
- end
- minetest.timers_to_add = {}
- for index, timer in ipairs(minetest.timers) do
- timer.time = timer.time - dtime
- if timer.time <= 0 then
- timer.func()
- minetest.timers[index] = nil
- end
- end
+ for _, timer in ipairs(minetest.timers_to_add) do
+ table.insert(minetest.timers, timer)
+ end
+ minetest.timers_to_add = {}
+ for index, timer in ipairs(minetest.timers) do
+ timer.time = timer.time - dtime
+ if timer.time <= 0 then
+ timer.func(timer.param)
+ table.remove(minetest.timers,index)
+ end
+ end
end)
-function minetest.after(time, func)
- table.insert(minetest.timers_to_add, {time=time, func=func})
+function minetest.after(time, func, param)
+ table.insert(minetest.timers_to_add, {time=time, func=func, param=param})
end
--
diff --git a/doc/lua_api.txt b/doc/lua_api.txt
index bfde0a870..3a5927e9c 100644
--- a/doc/lua_api.txt
+++ b/doc/lua_api.txt
@@ -467,8 +467,9 @@ minetest.sound_play(spec, parameters) -> handle
^ parameters = sound parameter table
minetest.sound_stop(handle)
-minetest.after(time, func)
+minetest.after(time, func, param)
^ Call function after time seconds
+^ param is optional; to pass multiple parameters, pass a table.
Global objects:
minetest.env - environment reference