mirror of
https://github.com/minetest-mods/mesecons.git
synced 2024-12-28 16:27:28 +01:00
Merge pull request #152 from CiaranG/timer
Add timer() function/event (node timer based) to luacontroller
This commit is contained in:
commit
38ff900274
@ -219,13 +219,19 @@ local getinterrupt = function(pos)
|
|||||||
return interrupt
|
return interrupt
|
||||||
end
|
end
|
||||||
|
|
||||||
local getdigiline_send = function (pos)
|
local handle_timer = function(pos, elapsed)
|
||||||
local digiline_send = function (channel, msg)
|
local err = lc_update(pos, {type="timer"})
|
||||||
if digiline then
|
if err then print(err) end
|
||||||
digiline:receptor_send(pos, digiline.rules.default, channel, msg)
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local gettimer = function(pos)
|
||||||
|
local timer = function (time)
|
||||||
|
if type(time) ~= "number" then return end
|
||||||
|
local nodetimer = minetest.get_node_timer(pos)
|
||||||
|
nodetimer:start(time)
|
||||||
end
|
end
|
||||||
return digiline_send
|
return timer
|
||||||
end
|
end
|
||||||
|
|
||||||
local create_environment = function(pos, mem, event)
|
local create_environment = function(pos, mem, event)
|
||||||
@ -239,7 +245,11 @@ local create_environment = function(pos, mem, event)
|
|||||||
pin = merge_portstates(vports, rports),
|
pin = merge_portstates(vports, rports),
|
||||||
port = vports,
|
port = vports,
|
||||||
interrupt = getinterrupt(pos),
|
interrupt = getinterrupt(pos),
|
||||||
digiline_send = getdigiline_send(pos),
|
timer = gettimer(pos),
|
||||||
|
digiline_msgs = {},
|
||||||
|
digiline_send = function(channel, msg)
|
||||||
|
table.insert(lc_digiline_msgs, {["channel"]=channel, ["msg"]=msg})
|
||||||
|
end,
|
||||||
mem = mem,
|
mem = mem,
|
||||||
tostring = tostring,
|
tostring = tostring,
|
||||||
tonumber = tonumber,
|
tonumber = tonumber,
|
||||||
@ -527,6 +537,7 @@ minetest.register_node(nodename, {
|
|||||||
if err then print(err) end
|
if err then print(err) end
|
||||||
reset_meta(pos, fields.code, err)
|
reset_meta(pos, fields.code, err)
|
||||||
end,
|
end,
|
||||||
|
on_timer = handle_timer,
|
||||||
sounds = default.node_sound_stone_defaults(),
|
sounds = default.node_sound_stone_defaults(),
|
||||||
mesecons = mesecons,
|
mesecons = mesecons,
|
||||||
digiline = digiline,
|
digiline = digiline,
|
||||||
|
Loading…
Reference in New Issue
Block a user