summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authortenplus1 <tenplus1@users.noreply.github.com>2020-09-23 18:11:56 +0100
committerGitHub <noreply@github.com>2020-09-23 19:11:56 +0200
commit34e3ede8eeb05e193e64ba3d055fc67959d87d86 (patch)
tree6657733c70e578cf0f92c3b711e7b0cbd12ae6b9 /builtin
parentadd68369a59af90f8b4203b53695521c6d657d6b (diff)
downloadminetest-34e3ede8eeb05e193e64ba3d055fc67959d87d86.tar.gz
minetest-34e3ede8eeb05e193e64ba3d055fc67959d87d86.tar.bz2
minetest-34e3ede8eeb05e193e64ba3d055fc67959d87d86.zip
Ability to remove minetest.after once set (#10103)
Diffstat (limited to 'builtin')
-rw-r--r--builtin/common/after.lua6
1 files changed, 4 insertions, 2 deletions
diff --git a/builtin/common/after.lua b/builtin/common/after.lua
index b314711c9..e20f292f0 100644
--- a/builtin/common/after.lua
+++ b/builtin/common/after.lua
@@ -31,11 +31,13 @@ function core.after(after, func, ...)
assert(tonumber(after) and type(func) == "function",
"Invalid minetest.after invocation")
local expire = time + after
- jobs[#jobs + 1] = {
+ local new_job = {
func = func,
expire = expire,
arg = {...},
- mod_origin = core.get_last_run_mod()
+ mod_origin = core.get_last_run_mod(),
}
+ jobs[#jobs + 1] = new_job
time_next = math.min(time_next, expire)
+ return { cancel = function() new_job.func = function() end end }
end