add locked frequency range, where only one transmitter is allowed

This commit is contained in:
techniX 2019-12-08 03:32:32 +02:00
parent 60746864e9
commit 5e3f36bb8a
2 changed files with 17 additions and 1 deletions

@ -1,11 +1,20 @@
function ham_radio.validate_frequency(frequency)
local transmission_is_allowed = true
local num_freq = tonumber(frequency)
local freq = tostring(num_freq)
if 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
transmission_is_allowed = false
end
end
return freq == frequency
and num_freq ~= nil
and num_freq == math.floor(num_freq)
and num_freq >= ham_radio.settings.frequency.min
and num_freq <= ham_radio.settings.frequency.max
and transmission_is_allowed
end
function ham_radio.find_transmitters(frequency)

@ -12,11 +12,18 @@ ham_radio = {
broadcast_color = '#607d8b',
broadcast_interval = 10, -- seconds
hud_pos = { x = 0.5, y = 0.8 },
-- radio frequency range
frequency = {
min = 0,
max = 9999999
},
beacon_frequency = { -- sub-range of frequency range
-- range where only one transmitter is permitted
locked_frequency = {
min = 100000,
max = 9999999
},
-- sub-range of frequency range
beacon_frequency = {
min = 1000000,
max = 9999999
},