mirror of
https://github.com/technix/ham_radio.git
synced 2025-01-24 13:01:26 +01:00
add locked frequency range, where only one transmitter is allowed
This commit is contained in:
parent
60746864e9
commit
5e3f36bb8a
@ -1,11 +1,20 @@
|
|||||||
function ham_radio.validate_frequency(frequency)
|
function ham_radio.validate_frequency(frequency)
|
||||||
|
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 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
|
return freq == frequency
|
||||||
and num_freq ~= nil
|
and num_freq ~= nil
|
||||||
and num_freq == math.floor(num_freq)
|
and num_freq == math.floor(num_freq)
|
||||||
and num_freq >= ham_radio.settings.frequency.min
|
and num_freq >= ham_radio.settings.frequency.min
|
||||||
and num_freq <= ham_radio.settings.frequency.max
|
and num_freq <= ham_radio.settings.frequency.max
|
||||||
|
and transmission_is_allowed
|
||||||
end
|
end
|
||||||
|
|
||||||
function ham_radio.find_transmitters(frequency)
|
function ham_radio.find_transmitters(frequency)
|
||||||
|
9
init.lua
9
init.lua
@ -12,11 +12,18 @@ ham_radio = {
|
|||||||
broadcast_color = '#607d8b',
|
broadcast_color = '#607d8b',
|
||||||
broadcast_interval = 10, -- seconds
|
broadcast_interval = 10, -- seconds
|
||||||
hud_pos = { x = 0.5, y = 0.8 },
|
hud_pos = { x = 0.5, y = 0.8 },
|
||||||
|
-- radio frequency range
|
||||||
frequency = {
|
frequency = {
|
||||||
min = 0,
|
min = 0,
|
||||||
max = 9999999
|
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,
|
min = 1000000,
|
||||||
max = 9999999
|
max = 9999999
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user