forked from nalc/global_exchange
Fix crash if an item doesn't exist anymore
This commit is contained in:
parent
b22b72f5c2
commit
9c8f62320e
@ -9,14 +9,15 @@ local S = minetest.get_translator("global_exchange")
|
|||||||
|
|
||||||
-- NALC split() function
|
-- NALC split() function
|
||||||
local function split(str, sep)
|
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 result = {}
|
||||||
local regex = ("([^%s]+)"):format(sep)
|
local regex = ("([^%s]+)"):format(sep)
|
||||||
for each in str:gmatch(regex) do
|
for each in str:gmatch(regex) do
|
||||||
if #each > 30 then
|
local sub = nil
|
||||||
each = string.sub(each, 1, 30).."..."
|
if #each > 25 then
|
||||||
|
sub = string.sub(each, 1, 25).."..."
|
||||||
end
|
end
|
||||||
table.insert(result, each)
|
table.insert(result, sub or each)
|
||||||
end
|
end
|
||||||
return result
|
return result
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user