From 63b9e98b07ce71efadd7c86723c2ce2b8cf85b14 Mon Sep 17 00:00:00 2001 From: techniX Date: Sun, 8 Dec 2019 17:10:46 +0200 Subject: [PATCH] allow empty frequency (turn off) --- helpers.lua | 3 +++ transmitter.lua | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/helpers.lua b/helpers.lua index 9c1ff72..d00f430 100644 --- a/helpers.lua +++ b/helpers.lua @@ -1,4 +1,7 @@ function ham_radio.validate_frequency(frequency) + 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) diff --git a/transmitter.lua b/transmitter.lua index 8125878..c953930 100644 --- a/transmitter.lua +++ b/transmitter.lua @@ -1,7 +1,12 @@ ham_radio.transmitter_update_infotext = function(meta) - local infotext = {'Frequency: ', meta:get_string("frequency")} + local frequency = meta:get_string("frequency") local broadcast_message = meta:get_string("broadcast_message") + if frequency == "" then + frequency = "--" + broadcast_message = "" + end + local infotext = {'Frequency: ', frequency} if broadcast_message ~= "" then table.insert(infotext, '\nBroadcast: "') table.insert(infotext, broadcast_message)