mirror of
https://github.com/minetest-mods/digtron.git
synced 2024-12-23 04:42:23 +01:00
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.
This commit is contained in:
parent
1de57191b0
commit
fdde32283a
@ -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
|
-- 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
|
if minetest.get_item_group(node.name, "digtron") == 4 then
|
||||||
local build_item = node_image.meta.inventory.main[1]
|
-- https://github.com/minetest-mods/digtron/issues/17 had a user encounter a crash here,
|
||||||
if build_item ~= "" then
|
-- adding logging to hopefully catch it if it happens again.
|
||||||
local build_item_def = minetest.registered_nodes[ItemStack(build_item):get_name()]
|
if node_image.meta.inventory.main ~= nil then
|
||||||
if build_item_def ~= nil then
|
local build_item = node_image.meta.inventory.main[1]
|
||||||
node_image.build_item_paramtype2 = build_item_def.paramtype2
|
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
|
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
|
||||||
end
|
end
|
||||||
return node_image
|
return node_image
|
||||||
|
Loading…
Reference in New Issue
Block a user