support node timer interval which is not 1 second

M  maidroid_tool/api.lua
This commit is contained in:
Hybrid Dog 2016-12-29 12:14:35 +01:00
parent a5e36b9c50
commit 73183a5a36
1 changed files with 2 additions and 2 deletions

View File

@ -39,7 +39,7 @@ function maidroid_tool.register_writer(nodename, options)
end
-- on_timer is a common callback.
local function on_timer(pos)
local function on_timer(pos, elapsed)
local meta = minetest.get_meta(pos)
local inventory = meta:get_inventory()
local main_list = inventory:get_list("main")
@ -52,7 +52,7 @@ function maidroid_tool.register_writer(nodename, options)
-- if time is positive, this node is active.
if time >= 0 then
if time <= duration then
meta:set_float("time", time + 1)
meta:set_float("time", time + elapsed)
meta:set_string("formspec", formspec.active(time))
else
meta:set_float("time", -1)