summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorheavygale <mail@heavygale.de>2018-05-31 16:06:56 +0200
committerrubenwardy <rw@rubenwardy.com>2018-05-31 15:06:56 +0100
commit21e1ce6675b8e42dd14957e2a7110236c44a19f2 (patch)
treece39079794c91f68554b9d18c0927db6172e1849
parent0ae58ad0c3f99567d34320208d2ca5305d0d161d (diff)
Fix convert_data crash when craft data is missing
Crash occurs when no data for "craft" is available in the old data, fixed with a additional check.
-rw-r--r--api.lua14
1 files changed, 8 insertions, 6 deletions
diff --git a/api.lua b/api.lua
index 17d9e09..2fe2e22 100644
--- a/api.lua
+++ b/api.lua
@@ -51,12 +51,14 @@ local function convert_data()
local ret = {}
local count = 0
- for modname, items in pairs(data[from]) do
- for itemname, value in pairs(items) do
- itemname = modname .. ":" .. itemname
- local key = minetest.registered_aliases[itemname] or itemname
- ret[key] = value
- count = count + value
+ if data[from] then
+ for modname, items in pairs(data[from]) do
+ for itemname, value in pairs(items) do
+ itemname = modname .. ":" .. itemname
+ local key = minetest.registered_aliases[itemname] or itemname
+ ret[key] = value
+ count = count + value
+ end
end
end