Allow minetest.after to take a variable number of arguments
authorJeija <norrepli@gmail.com>
Mon, 11 Feb 2013 08:58:58 +0000 (09:58 +0100)
committerkwolekr <kwolekr@minetest.net>
Sun, 17 Mar 2013 04:23:30 +0000 (00:23 -0400)
builtin/misc.lua
doc/lua_api.txt

index 496435b33b41999a2833ef49b9968faa9c56e859..2cc76e8ec5aebdf40be6142a75ad623e180eaf34 100644 (file)
@@ -14,14 +14,14 @@ minetest.register_globalstep(function(dtime)
        for index, timer in ipairs(minetest.timers) do
                timer.time = timer.time - dtime
                if timer.time <= 0 then
-                       timer.func(timer.param)
+                       timer.func(unpack(timer.args))
                        table.remove(minetest.timers,index)
                end
        end
 end)
 
-function minetest.after(time, func, param)
-       table.insert(minetest.timers_to_add, {time=time, func=func, param=param})
+function minetest.after(time, func, ...)
+       table.insert(minetest.timers_to_add, {time=time, func=func, args=arg})
 end
 
 function minetest.check_player_privs(name, privs)
index 809d3d9d09a6c70e07ead766241fe093b9050b98..eb05d117ebbe54309d2905d30b1234948c1b8a20 100644 (file)
@@ -977,9 +977,9 @@ minetest.sound_play(spec, parameters) -> handle
 minetest.sound_stop(handle)
 
 Timing:
-minetest.after(time, func, param)
+minetest.after(time, func, ...)
 ^ Call function after time seconds
-^ param is optional; to pass multiple parameters, pass a table.
+^ Optional: Variable number of arguments that are passed to func
 
 Server:
 minetest.request_shutdown() -> request for server shutdown