mirror of
https://github.com/technix/ham_radio.git
synced 2024-08-19 12:44:12 +02:00
bugfix: allow receiver to tune to beacons
This commit is contained in:
parent
11490054e1
commit
89581339a3
@ -1,11 +1,11 @@
|
|||||||
function ham_radio.validate_frequency(frequency)
|
function ham_radio.validate_frequency(frequency, is_receiver)
|
||||||
if frequency == "" then
|
if frequency == "" then
|
||||||
return true -- empty frequency is allowed to disable transmitter/receiver
|
return true -- empty frequency is allowed to disable transmitter/receiver
|
||||||
end
|
end
|
||||||
local transmission_is_allowed = true
|
local transmission_is_allowed = true
|
||||||
local num_freq = tonumber(frequency)
|
local num_freq = tonumber(frequency)
|
||||||
local freq = tostring(num_freq)
|
local freq = tostring(num_freq)
|
||||||
if next(ham_radio.find_transmitters(frequency)) then
|
if is_receiver ~= nil and next(ham_radio.find_transmitters(frequency)) then
|
||||||
if num_freq >= ham_radio.settings.locked_frequency.min
|
if num_freq >= ham_radio.settings.locked_frequency.min
|
||||||
and num_freq <= ham_radio.settings.locked_frequency.max then
|
and num_freq <= ham_radio.settings.locked_frequency.max then
|
||||||
-- transmitter is in locked frequency range
|
-- transmitter is in locked frequency range
|
||||||
|
@ -37,7 +37,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
|||||||
if formname ~= "ham_radio:configure_handheld_receiver" or not minetest.is_player(player) then
|
if formname ~= "ham_radio:configure_handheld_receiver" or not minetest.is_player(player) then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
if not ham_radio.validate_frequency(fields.frequency) then
|
if not ham_radio.validate_frequency(fields.frequency, true) then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
local item = player:get_wielded_item()
|
local item = player:get_wielded_item()
|
||||||
|
Loading…
Reference in New Issue
Block a user