Skip to content

Instantly share code, notes, and snippets.

@rubenwardy rubenwardy/ruben.lua Secret
Last active Apr 11, 2017

Embed
What would you like to do?
local s = assert(minetest.get_mod_storage())
local timer_def = Timer("mod:event", {
storage = s,
func = function(put, params, here)
local elapsed = this:get_elapsed()
print("fn1: ", elapsed)
end
})
function on_hit(player)
local t1 = timer_def:interval(0.5, put, params, here)
end
function on_punch(player)
local t2 = timer_def:interval(0.5, put, params, here)
end
local s = assert(minetest.get_mod_storage())
local mytimerfunc1 = function(elapsed)
print("fn1: ", elapsed)
end
-- Required to make timers persist
Timer(mytimerfunc1, {
storage = s,
key = "timer_data",
interval = 2.0,
repeats = true,
})
function on_hit(player)
Timer(mytimerfunc1, {
storage = s,
key = "timer_data",
interval = 2.0,
repeats = true,
})
end)
function on_punch(player)
Timer(mytimerfunc1, {
storage = s,
key = "timer_data",
interval = 2.0,
repeats = true,
})
end)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.