digiline: plaintext messages for broadcast

This commit is contained in:
techniX 2019-12-08 16:48:36 +02:00
parent 125b6a0186
commit 735d285c67
4 changed files with 21 additions and 6 deletions

@ -18,13 +18,11 @@ if minetest.get_modpath("technic") then
battery = 'technic:battery'
end
minetest.register_craftitem("ham_radio:circuit", {
description = "Radio Circuit",
inventory_image = "ham_radio_circuit.png",
})
minetest.register_craft({
output = "ham_radio:circuit",
recipe = {
@ -33,7 +31,6 @@ minetest.register_craft({
}
})
minetest.register_craft({
output = "ham_radio:handheld_receiver",
recipe = {

@ -1,12 +1,29 @@
ham_radio.digiline_effector = function(pos, _, channel, msg)
local digiline_channel = ham_radio.settings.digiline_channel -- static channel
local command_channel = ham_radio.settings.digiline_channel -- static channel
local broadcast_channel = ham_radio.settings.digiline_broadcast_channel
if type(msg) ~= "table" or channel ~= digiline_channel then
if channel ~= command_channel and channel ~= broadcast_channel then
return
end
local meta = minetest.get_meta(pos)
-- broadcast channel - text message
if channel == broadcast_channel then
if type(msg) == "string" then
meta:set_string("broadcast_message", msg)
ham_radio.transmitter_update_infotext(meta)
ham_radio.save_transmitter(pos, meta)
end
return
end
-- command channel
if type(msg) ~= "table" then
return
end
if msg.command == "get" then
digilines.receptor_send(pos, digilines.rules.default, digiline_channel, {
frequency = meta:get_string("frequency"),

@ -28,6 +28,7 @@ ham_radio = {
max = 9999999
},
digiline_channel = "ham_radio",
digiline_broadcast_channel = "ham_radio_broadcast",
}
}

@ -76,7 +76,7 @@ minetest.register_node("ham_radio:transmitter", {
digiline = {
receptor = {action = function() end},
effector = {
action = ham_radio.digiline_effector
action = ham_radio.digiline_effector
},
},
});