From b5e8068a99f9bf1538589614624d05c7614f13cb Mon Sep 17 00:00:00 2001 From: Gabriel PĂ©rez-Cerezo Date: Sat, 20 Jul 2019 19:43:38 +0200 Subject: math.floor triggers error if it gets something nil --- advtrains_line_automation/stoprail.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'advtrains_line_automation') diff --git a/advtrains_line_automation/stoprail.lua b/advtrains_line_automation/stoprail.lua index ec4994b..0db474f 100644 --- a/advtrains_line_automation/stoprail.lua +++ b/advtrains_line_automation/stoprail.lua @@ -4,7 +4,10 @@ local function to_int(n) --- Disallow floating-point numbers - return math.floor(tonumber(n)) + local k = tonumber(n) + if k then + return math.floor(k) + end end local function updatemeta(pos) -- cgit v1.2.3