From c55e3fc9d52db78e565b1765db54b10aa87a0367 Mon Sep 17 00:00:00 2001 From: BuckarooBanzay Date: Fri, 13 Oct 2023 09:55:03 +0200 Subject: [PATCH] digilines lcd support --- init.lua | 4 ++++ mesecons/lcd.lua | 27 +++++++++++++++++++++++++++ mod.conf | 13 ++++++++++++- 3 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 mesecons/lcd.lua diff --git a/init.lua b/init.lua index 4d6a396..2eadc62 100644 --- a/init.lua +++ b/init.lua @@ -37,6 +37,10 @@ if minetest.get_modpath("mesecons_switch") and minetest.get_modpath("mesecons_li dofile(MP.."/mesecons/lightstones.lua") dofile(MP.."/mesecons/switch.lua") dofile(MP.."/mesecons/register_tool.lua") + + if minetest.get_modpath("digilines") then + dofile(MP.."/mesecons/lcd.lua") + end end if not minetest.get_modpath("xp_redo") then diff --git a/mesecons/lcd.lua b/mesecons/lcd.lua new file mode 100644 index 0000000..11c7a4d --- /dev/null +++ b/mesecons/lcd.lua @@ -0,0 +1,27 @@ +local lcd_name = "digilines:lcd" + +mtui.mesecons.allowed_nodes[lcd_name] = true + +local lcd_def = assert(minetest.registered_nodes[lcd_name]) +local old_effector_action = assert(lcd_def.digilines.effector.action) + +lcd_def.digilines.effector.action = function(pos, node, channel, msg) + old_effector_action(pos, node, channel, msg) + + if type(msg) ~= "string" then + return + end + + local meta = minetest.get_meta(pos) + local setchan = meta:get_string("channel") + if setchan ~= channel then return end + + mtui.send_command({ + type = "mesecons_event", + data = { + pos = pos, + state = msg, + nodename = node.name + } + }) +end diff --git a/mod.conf b/mod.conf index eebdd6b..e647d39 100644 --- a/mod.conf +++ b/mod.conf @@ -1,2 +1,13 @@ name = mtui -optional_depends = mail, monitoring, mtt, monitoring, xp_redo, technic_chests, beerchat, mesecons_switch, mesecons_lightstone \ No newline at end of file +optional_depends = """ +mail, +monitoring, +mtt, +monitoring, +xp_redo, +technic_chests, +beerchat, +mesecons_switch, +mesecons_lightstone, +digilines +""" \ No newline at end of file