diff options
author | cheapie <no-email-for-you@example.com> | 2016-09-21 21:13:52 -0500 |
---|---|---|
committer | cheapie <no-email-for-you@example.com> | 2016-09-21 21:13:52 -0500 |
commit | 0e3b6dda835f3b71b636670a898c277db69b77e1 (patch) | |
tree | a7624bc7b277d4230f6ea061c268c655a43522cd | |
parent | 551b470b161632e548249f19e5b212baf92a6c67 (diff) | |
download | digistuff-0e3b6dda835f3b71b636670a898c277db69b77e1.tar digistuff-0e3b6dda835f3b71b636670a898c277db69b77e1.tar.gz digistuff-0e3b6dda835f3b71b636670a898c277db69b77e1.tar.bz2 digistuff-0e3b6dda835f3b71b636670a898c277db69b77e1.tar.xz digistuff-0e3b6dda835f3b71b636670a898c277db69b77e1.zip |
Add bundled command support
-rw-r--r-- | init.lua | 25 |
1 files changed, 19 insertions, 6 deletions
@@ -80,12 +80,7 @@ digistuff.ts_on_receive_fields = function (pos, formname, fields, sender) end end -digistuff.ts_on_digiline_receive = function (pos, node, channel, msg) - local meta = minetest.get_meta(pos) - local setchan = meta:get_string("channel") - if channel ~= setchan then return end - if type(msg) ~= "table" then return end - local data = minetest.deserialize(meta:get_string("data")) or {} +digistuff.process_command = function (meta, data, msg) if msg.command == "clear" then data = {} elseif msg.command == "addimage" then @@ -217,6 +212,24 @@ digistuff.ts_on_digiline_receive = function (pos, node, channel, msg) elseif msg.command == "unlock" then meta:set_int("locked",0) end + return data +end + +digistuff.ts_on_digiline_receive = function (pos, node, channel, msg) + local meta = minetest.get_meta(pos) + local setchan = meta:get_string("channel") + if channel ~= setchan then return end + if type(msg) ~= "table" then return end + local data = minetest.deserialize(meta:get_string("data")) or {} + if msg.command then + data = digistuff.process_command(meta,data,msg) + else + for _,i in ipairs(msg) do + if i.command then + data = digistuff.process_command(meta,data,i) + end + end + end meta:set_string("data",minetest.serialize(data)) digistuff.update_ts_formspec(pos) end |