2019-12-08 00:29:27 +01:00
|
|
|
ham_radio.digiline_effector = function(pos, _, channel, msg)
|
2019-12-08 15:48:36 +01:00
|
|
|
local command_channel = ham_radio.settings.digiline_channel -- static channel
|
|
|
|
local broadcast_channel = ham_radio.settings.digiline_broadcast_channel
|
2019-12-08 00:29:27 +01:00
|
|
|
|
2019-12-08 15:48:36 +01:00
|
|
|
if channel ~= command_channel and channel ~= broadcast_channel then
|
2019-12-08 00:29:27 +01:00
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
local meta = minetest.get_meta(pos)
|
|
|
|
|
2019-12-08 15:48:36 +01:00
|
|
|
-- 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
|
|
|
|
|
2019-12-08 00:29:27 +01:00
|
|
|
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
|
|
|
|
|
2019-12-08 17:42:40 +01:00
|
|
|
elseif msg.command == "rds" or msg.command == "message" or msg.command == "rds_message" then
|
2019-12-08 00:29:27 +01:00
|
|
|
meta:set_string("broadcast_message", msg.value)
|
|
|
|
ham_radio.transmitter_update_infotext(meta)
|
|
|
|
ham_radio.save_transmitter(pos, meta)
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|