From 9c8f62320ef6f6e6d4aaa1e2a18addc72b2ef674 Mon Sep 17 00:00:00 2001 From: sys4 Date: Fri, 9 Apr 2021 17:29:18 +0200 Subject: [PATCH] Fix crash if an item doesn't exist anymore --- exchange_machine.lua | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/exchange_machine.lua b/exchange_machine.lua index 5740d12..61bf09e 100644 --- a/exchange_machine.lua +++ b/exchange_machine.lua @@ -9,14 +9,15 @@ local S = minetest.get_translator("global_exchange") -- NALC split() function local function split(str, sep) - if not str then return nil end + if not str then return "Item doesn't exist" end local result = {} local regex = ("([^%s]+)"):format(sep) for each in str:gmatch(regex) do - if #each > 30 then - each = string.sub(each, 1, 30).."..." + local sub = nil + if #each > 25 then + sub = string.sub(each, 1, 25).."..." end - table.insert(result, each) + table.insert(result, sub or each) end return result end