diff options
author | Jeija <norrepli@gmail.com> | 2014-03-16 21:05:49 +0100 |
---|---|---|
committer | Jeija <norrepli@gmail.com> | 2014-03-16 21:05:49 +0100 |
commit | 38ff900274517be1009d01cb7af1318e6ea456b4 (patch) | |
tree | 9539e68406e20683a6829153e0a6c59b37a1aacb /mesecons_luacontroller | |
parent | 8440d05e8c0fe7d64edccc6f8581c63f42087151 (diff) | |
parent | 9eda62df7b45659ff704db9a63a633a6bc4f70a7 (diff) |
Merge pull request #152 from CiaranG/timer
Add timer() function/event (node timer based) to luacontroller
Diffstat (limited to 'mesecons_luacontroller')
-rw-r--r-- | mesecons_luacontroller/init.lua | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/mesecons_luacontroller/init.lua b/mesecons_luacontroller/init.lua index 2cfa67e..5e0982e 100644 --- a/mesecons_luacontroller/init.lua +++ b/mesecons_luacontroller/init.lua @@ -219,13 +219,19 @@ local getinterrupt = function(pos) return interrupt end -local getdigiline_send = function (pos) - local digiline_send = function (channel, msg) - if digiline then - digiline:receptor_send(pos, digiline.rules.default, channel, msg) - end +local handle_timer = function(pos, elapsed) + local err = lc_update(pos, {type="timer"}) + if err then print(err) end + return false +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 - return digiline_send + return timer end local create_environment = function(pos, mem, event) @@ -239,7 +245,11 @@ local create_environment = function(pos, mem, event) pin = merge_portstates(vports, rports), port = vports, 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, tostring = tostring, tonumber = tonumber, @@ -527,6 +537,7 @@ minetest.register_node(nodename, { if err then print(err) end reset_meta(pos, fields.code, err) end, + on_timer = handle_timer, sounds = default.node_sound_stone_defaults(), mesecons = mesecons, digiline = digiline, |