summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFaceDeer <derksenmobile@gmail.com>2017-12-31 18:21:44 -0700
committerFaceDeer <derksenmobile@gmail.com>2017-12-31 18:21:44 -0700
commitfdde32283afd1327a09872214b09a611002e95fa (patch)
tree2ed99aefb6d084f0ee24cf0aeb83fa8df204f1b6
parent1de57191b0afa4df320c4319de0d7ea6b33d2b27 (diff)
add logging and crash-proofing for issue 17
A user has reported a crash that appears to involve a builder node (group 4) that lacks a "main" inventory somehow. This code prevents a crash in this circumstance and logs the node_image to hopefully identify the culprit.
-rw-r--r--class_layout.lua16
1 files changed, 11 insertions, 5 deletions
diff --git a/class_layout.lua b/class_layout.lua
index df4a3d5..cf9a7bb 100644
--- a/class_layout.lua
+++ b/class_layout.lua
@@ -18,12 +18,18 @@ local get_node_image = function(pos, node)
-- Record what kind of thing we've got in a builder node so its facing can be rotated properly
if minetest.get_item_group(node.name, "digtron") == 4 then
- local build_item = node_image.meta.inventory.main[1]
- if build_item ~= "" then
- local build_item_def = minetest.registered_nodes[ItemStack(build_item):get_name()]
- if build_item_def ~= nil then
- node_image.build_item_paramtype2 = build_item_def.paramtype2
+ -- https://github.com/minetest-mods/digtron/issues/17 had a user encounter a crash here,
+ -- adding logging to hopefully catch it if it happens again.
+ if node_image.meta.inventory.main ~= nil then
+ local build_item = node_image.meta.inventory.main[1]
+ if build_item ~= "" then
+ local build_item_def = minetest.registered_nodes[ItemStack(build_item):get_name()]
+ if build_item_def ~= nil then
+ node_image.build_item_paramtype2 = build_item_def.paramtype2
+ end
end
+ else
+ minetest.log("error", string.format("Digtron node in group 4 lacks a 'main' inventory. Please update the issue at https://github.com/minetest-mods/digtron/issues/17. Node image: %s", dump(node_image)))
end
end
return node_image