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
|
2019-12-08 18:07:18 +01:00
|
|
|
local rds_channel = ham_radio.settings.digiline_rds_channel
|
2019-12-08 00:29:27 +01:00
|
|
|
|
2019-12-08 18:07:18 +01:00
|
|
|
if channel ~= command_channel and channel ~= rds_channel then
|
2019-12-08 00:29:27 +01:00
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
local meta = minetest.get_meta(pos)
|
|
|
|
|
2019-12-08 18:07:18 +01:00
|
|
|
-- RDS channel - text message
|
|
|
|
if channel == rds_channel then
|
2019-12-08 15:48:36 +01:00
|
|
|
if type(msg) == "string" then
|
2019-12-08 18:07:18 +01:00
|
|
|
meta:set_string("rds_message", msg)
|
2019-12-08 15:48:36 +01:00
|
|
|
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"),
|
2019-12-08 18:07:18 +01:00
|
|
|
rds_message = meta:get_string("rds_message"),
|
2019-12-08 00:29:27 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
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 18:07:18 +01:00
|
|
|
meta:set_string("rds_message", msg.value)
|
2019-12-08 00:29:27 +01:00
|
|
|
ham_radio.transmitter_update_infotext(meta)
|
|
|
|
ham_radio.save_transmitter(pos, meta)
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|