mirror of
https://github.com/technix/ham_radio.git
synced 2024-11-30 10:53:46 +01:00
enable/disable RDS messages
This commit is contained in:
parent
fb0a1d7fea
commit
6c7449761c
@ -5,7 +5,7 @@ function ham_radio.get_broadcast_messages(frequency)
|
||||
if transmitter.broadcast_message ~= "" then
|
||||
-- construct message
|
||||
local message = table.concat({
|
||||
'[ Radio Broadcast: ',
|
||||
'[ Radio | ',
|
||||
transmitter.operated_by,
|
||||
' ] ',
|
||||
transmitter.broadcast_message,
|
||||
@ -25,7 +25,19 @@ function ham_radio:update_broadcast(player)
|
||||
return
|
||||
end
|
||||
|
||||
local frequency = item:get_meta():get_string("frequency")
|
||||
local meta = item:get_meta()
|
||||
local frequency = meta:get_string("frequency")
|
||||
local broadcast_disabled = meta:get_string("broadcast_disabled")
|
||||
|
||||
if frequency == "" then
|
||||
return
|
||||
end
|
||||
|
||||
if broadcast_disabled == "true" then
|
||||
-- disabled receiving broadcast messages
|
||||
ham_radio.player_broadcasts[name] = nil
|
||||
return
|
||||
end
|
||||
|
||||
if ham_radio.player_broadcasts[name] == nil then
|
||||
ham_radio.player_broadcasts[name] = ham_radio.get_broadcast_messages(frequency)
|
||||
|
@ -22,5 +22,5 @@ ham_radio.settings = {
|
||||
},
|
||||
-- digiline config
|
||||
digiline_channel = "ham_radio",
|
||||
digiline_broadcast_channel = "ham_radio_broadcast",
|
||||
digiline_broadcast_channel = "ham_radio_rds",
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ ham_radio.digiline_effector = function(pos, _, channel, msg)
|
||||
ham_radio.save_transmitter(pos, meta)
|
||||
end
|
||||
|
||||
elseif msg.command == "broadcast" or msg.command == "message" or msg.command == "broadcast_message" then
|
||||
elseif msg.command == "rds" or msg.command == "message" or msg.command == "rds_message" then
|
||||
meta:set_string("broadcast_message", msg.value)
|
||||
ham_radio.transmitter_update_infotext(meta)
|
||||
ham_radio.save_transmitter(pos, meta)
|
||||
|
40
hud.lua
40
hud.lua
@ -39,12 +39,21 @@ function ham_radio.toggle_hud(player)
|
||||
hud_elem_type = "text",
|
||||
text = "",
|
||||
position = hud_pos,
|
||||
offset = { x = 0, y = 5 },
|
||||
alignment = 0,
|
||||
number = 0xFFFFFF,
|
||||
offset = { x = -220, y = 5 },
|
||||
alignment = { x = 1, y = 0},
|
||||
number = 0x999999,
|
||||
scale= { x = 100, y = 20 },
|
||||
}),
|
||||
signal_meter = player:hud_add({
|
||||
broadcast = player:hud_add({
|
||||
hud_elem_type = "text",
|
||||
text = "",
|
||||
position = hud_pos,
|
||||
offset = { x = 220, y = 5 },
|
||||
alignment = { x = -1, y = 0},
|
||||
number = 0x999999,
|
||||
scale= { x = 100, y = 20 },
|
||||
}),
|
||||
signal_meter = player:hud_add({
|
||||
hud_elem_type = "image",
|
||||
position = hud_pos,
|
||||
offset = { x = -220, y = 35 },
|
||||
@ -52,8 +61,8 @@ function ham_radio.toggle_hud(player)
|
||||
scale = { x = 2, y = 1 },
|
||||
alignment = { x = 1, y = 0 },
|
||||
}),
|
||||
signal_level = player:hud_add({
|
||||
hud_elem_type = "image",
|
||||
signal_level = player:hud_add({
|
||||
hud_elem_type = "image",
|
||||
position = hud_pos,
|
||||
offset = { x = -220, y = 35 },
|
||||
text = "ham_radio_hud_indicator_full.png",
|
||||
@ -86,8 +95,23 @@ function ham_radio:update_hud_display(player)
|
||||
end
|
||||
end
|
||||
end
|
||||
local text = "FQ "..tostring(meta:get_string("frequency"))
|
||||
player:hud_change(self.playerhuds[name].frequency, "text", text)
|
||||
|
||||
if frequency == "" then
|
||||
player:hud_change(self.playerhuds[name].frequency, "text", "FQ ---")
|
||||
player:hud_change(self.playerhuds[name].frequency, "number", "0x999999")
|
||||
else
|
||||
player:hud_change(self.playerhuds[name].frequency, "text", "FQ "..frequency)
|
||||
player:hud_change(self.playerhuds[name].frequency, "number", "0xFCAD00")
|
||||
end
|
||||
|
||||
if meta:get_string("broadcast_disabled") == "" then
|
||||
player:hud_change(self.playerhuds[name].broadcast, "text", "RDS ON")
|
||||
player:hud_change(self.playerhuds[name].broadcast, "number", "0xFCAD00")
|
||||
else
|
||||
player:hud_change(self.playerhuds[name].broadcast, "text", "RDS off")
|
||||
player:hud_change(self.playerhuds[name].broadcast, "number", "0x999999")
|
||||
end
|
||||
|
||||
player:hud_change(
|
||||
self.playerhuds[name].signal_level,
|
||||
"scale",
|
||||
|
12
receiver.lua
12
receiver.lua
@ -3,6 +3,7 @@ minetest.register_tool("ham_radio:handheld_receiver", {
|
||||
wield_image = "ham_radio_receiver_handheld.png",
|
||||
inventory_image = "ham_radio_receiver_handheld.png",
|
||||
groups = { disable_repair = 1 },
|
||||
-- left click - change frequency
|
||||
on_use = function(itemstack, user, pointed_thing)
|
||||
local meta = itemstack:get_meta()
|
||||
local frequency = meta:get_string("frequency")
|
||||
@ -19,6 +20,17 @@ minetest.register_tool("ham_radio:handheld_receiver", {
|
||||
)
|
||||
return itemstack
|
||||
end,
|
||||
-- right click - RDS on/off
|
||||
on_secondary_use = function(itemstack, user, pointed_thing)
|
||||
local meta = itemstack:get_meta()
|
||||
local is_broadcast_disabled = meta:get_string("broadcast_disabled")
|
||||
if is_broadcast_disabled == "" then
|
||||
meta:set_string("broadcast_disabled", "true")
|
||||
else
|
||||
meta:set_string("broadcast_disabled", "")
|
||||
end
|
||||
return itemstack
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
|
@ -43,7 +43,7 @@ minetest.register_node("ham_radio:transmitter", {
|
||||
"tooltip[frequency;Integer number ",
|
||||
ham_radio.settings.frequency.min,"-",
|
||||
ham_radio.settings.frequency.max, "]",
|
||||
"field[0.25,3.5;7,1;broadcast_message;Broadcast message;${broadcast_message}]",
|
||||
"field[0.25,3.5;7,1;broadcast_message;RDS message;${broadcast_message}]",
|
||||
"button_exit[2,4.5;3,1;;Done]"
|
||||
},'')
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user