mirror of
https://github.com/technix/ham_radio.git
synced 2025-03-01 05:34:36 +01:00
Digiline receiver: load new RDS immediately
This commit is contained in:
@ -78,8 +78,10 @@ ham_radio.digiline_effector_receiver = function(pos, _, channel, msg)
|
|||||||
local validate = ham_radio.validate_frequency(new_frequency, true)
|
local validate = ham_radio.validate_frequency(new_frequency, true)
|
||||||
if validate.result then
|
if validate.result then
|
||||||
meta:set_string("frequency", new_frequency)
|
meta:set_string("frequency", new_frequency)
|
||||||
ham_radio.reset_receiver(pos)
|
-- load new RDS messages
|
||||||
ham_radio.receiver_update_infotext(meta)
|
local poshash = minetest.pos_to_string(pos, 0)
|
||||||
|
ham_radio.receiver_rds[poshash] = ham_radio.get_rds_messages(new_frequency, true)
|
||||||
|
ham_radio.get_next_rds_message(poshash, meta)
|
||||||
end
|
end
|
||||||
digilines.receptor_send(pos, digilines.rules.default, command_channel, {
|
digilines.receptor_send(pos, digilines.rules.default, command_channel, {
|
||||||
update = 'frequency',
|
update = 'frequency',
|
||||||
|
@ -99,23 +99,25 @@ minetest.register_abm(
|
|||||||
action = function(pos, node)
|
action = function(pos, node)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local frequency = meta:get_string("frequency")
|
local frequency = meta:get_string("frequency")
|
||||||
|
|
||||||
if frequency == "" then
|
if frequency == "" then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local poshash = minetest.pos_to_string(pos, 0)
|
local poshash = minetest.pos_to_string(pos, 0)
|
||||||
|
|
||||||
if ham_radio.receiver_rds[poshash] == nil or not next(ham_radio.receiver_rds[poshash]) then
|
if ham_radio.receiver_rds[poshash] == nil or not next(ham_radio.receiver_rds[poshash]) then
|
||||||
-- when all RDS messages are shown, reload them again
|
-- when all RDS messages are shown, reload them again
|
||||||
ham_radio.receiver_rds[poshash] = ham_radio.get_rds_messages(frequency, true)
|
ham_radio.receiver_rds[poshash] = ham_radio.get_rds_messages(frequency, true)
|
||||||
end
|
end
|
||||||
|
ham_radio.get_next_rds_message(poshash, meta)
|
||||||
local message = table.remove(ham_radio.receiver_rds[poshash])
|
|
||||||
if message ~= nil then
|
|
||||||
meta:set_string('rds_message', message)
|
|
||||||
ham_radio.receiver_update_infotext(meta)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
ham_radio.get_next_rds_message = function (poshash, meta)
|
||||||
|
local message = table.remove(ham_radio.receiver_rds[poshash])
|
||||||
|
if message ~= nil then
|
||||||
|
meta:set_string('rds_message', message)
|
||||||
|
ham_radio.receiver_update_infotext(meta)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
Reference in New Issue
Block a user