From 9c9ec8ab4a9a2c1eb839e37d715b817f3b3f1bdf Mon Sep 17 00:00:00 2001 From: techniX Date: Sun, 8 Dec 2019 01:29:27 +0200 Subject: [PATCH] digiline support --- digiline.lua | 30 ++++++++++++++++++++++++++++++ init.lua | 4 +++- transmitter.lua | 9 ++++++++- 3 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 digiline.lua diff --git a/digiline.lua b/digiline.lua new file mode 100644 index 0000000..ed9e1dd --- /dev/null +++ b/digiline.lua @@ -0,0 +1,30 @@ +ham_radio.digiline_effector = function(pos, _, channel, msg) + local digiline_channel = ham_radio.settings.digiline_channel -- static channel + + if type(msg) ~= "table" or channel ~= digiline_channel then + return + end + + local meta = minetest.get_meta(pos) + + if msg.command == "get" then + digilines.receptor_send(pos, digilines.rules.default, digiline_channel, { + frequency = meta:get_string("frequency"), + broadcast_message = meta:get_string("broadcast_message"), + }) + + elseif msg.command == "frequency" then + local new_frequency = msg.value + if ham_radio.validate_frequency(new_frequency) then + meta:set_string("frequency", new_frequency) + ham_radio.transmitter_update_infotext(meta) + ham_radio.save_transmitter(pos, meta) + end + + elseif msg.command == "broadcast" or msg.command == "message" or msg.command == "broadcast_message" then + meta:set_string("broadcast_message", msg.value) + ham_radio.transmitter_update_infotext(meta) + ham_radio.save_transmitter(pos, meta) + + end +end \ No newline at end of file diff --git a/init.lua b/init.lua index a8a2c25..ac357f8 100644 --- a/init.lua +++ b/init.lua @@ -15,7 +15,8 @@ ham_radio = { frequency = { min = 0, max = 9999999 - } + }, + digiline_channel = "ham_radio", } } @@ -44,6 +45,7 @@ end dofile(modpath.."/helpers.lua") dofile(modpath.."/craft.lua") +dofile(modpath.."/digiline.lua") dofile(modpath.."/transmitter.lua") dofile(modpath.."/receiver.lua") dofile(modpath.."/broadcast.lua") diff --git a/transmitter.lua b/transmitter.lua index af62a65..8fc52ce 100644 --- a/transmitter.lua +++ b/transmitter.lua @@ -71,5 +71,12 @@ minetest.register_node("ham_radio:transmitter", { end, after_dig_node = function(pos, oldnode, oldmetadata, player) ham_radio.delete_transmitter(pos) - end + end, + -- digiline + digiline = { + receptor = {action = function() end}, + effector = { + action = ham_radio.digiline_effector + }, + }, });