aboutsummaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2012-03-27 08:17:42 +0300
committerPerttu Ahola <celeron55@gmail.com>2012-03-27 08:17:42 +0300
commitfa24e6b99581d56fd1a898d9eae7764a1cb48041 (patch)
treeb0744ca62264a796f1776e5c5bbb859389e6821f /builtin
parent37b64ff616df3475e228d6beb3727de2afd2b6c2 (diff)
downloadminetest-fa24e6b99581d56fd1a898d9eae7764a1cb48041.tar.gz
minetest-fa24e6b99581d56fd1a898d9eae7764a1cb48041.tar.bz2
minetest-fa24e6b99581d56fd1a898d9eae7764a1cb48041.zip
Fix and extend minetest.after(time, func, param)
Diffstat (limited to 'builtin')
-rw-r--r--builtin/builtin.lua26
1 files changed, 13 insertions, 13 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
--