bugfix: allow receiver to tune to beacons

This commit is contained in:
techniX 2019-12-08 20:57:23 +02:00
parent 11490054e1
commit 89581339a3
2 changed files with 3 additions and 3 deletions

@ -1,11 +1,11 @@
function ham_radio.validate_frequency(frequency)
function ham_radio.validate_frequency(frequency, is_receiver)
if frequency == "" then
return true -- empty frequency is allowed to disable transmitter/receiver
end
local transmission_is_allowed = true
local num_freq = tonumber(frequency)
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
and num_freq <= ham_radio.settings.locked_frequency.max then
-- 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
return false
end
if not ham_radio.validate_frequency(fields.frequency) then
if not ham_radio.validate_frequency(fields.frequency, true) then
return false
end
local item = player:get_wielded_item()