Toggle RDS on shift+click

This commit is contained in:
Serhii Mozhaiskyi 2019-12-13 13:35:52 +02:00
parent 652183d253
commit 7205e8a69b
2 changed files with 12 additions and 12 deletions

@ -31,7 +31,7 @@ Beacon is a simplified transmitter. After placement it automatically tunes on a
Handheld receiver is a wielded tool.
- Left click opens configuration dialog to set frequency. Empty string turns receiver off.
- Right click toggles reception of RDS messages.
- Shift + left click toggles reception of RDS messages.
When receiver is tuned to a frequency where at least one transmitter is present, HUD signal meter bar shows signal power. The signal power depends on distance and direction to the transmitter.

@ -5,7 +5,18 @@ minetest.register_tool("ham_radio:handheld_receiver", {
groups = { disable_repair = 1 },
-- left click - change frequency
on_use = function(itemstack, user, pointed_thing)
local keys = user:get_player_control()
local meta = itemstack:get_meta()
if keys.sneak then
-- left click with shift - RDS on/off
local is_rds_disabled = meta:get_string("rds_disabled")
if is_rds_disabled == "" then
meta:set_string("rds_disabled", "true")
else
meta:set_string("rds_disabled", "")
end
return itemstack
end
local frequency = meta:get_string("frequency")
minetest.show_formspec(user:get_player_name(), "ham_radio:configure_handheld_receiver",
table.concat({
@ -19,17 +30,6 @@ 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_rds_disabled = meta:get_string("rds_disabled")
if is_rds_disabled == "" then
meta:set_string("rds_disabled", "true")
else
meta:set_string("rds_disabled", "")
end
return itemstack
end
})