From bbc530a0676fbf2c06f55b3cd8ed13638eea2be3 Mon Sep 17 00:00:00 2001 From: Vanessa Ezekowitz Date: Sun, 24 Aug 2014 11:51:43 -0400 Subject: fix undefined node crash --- item_transport.lua | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/item_transport.lua b/item_transport.lua index 02ef5f8..c378d6e 100755 --- a/item_transport.lua +++ b/item_transport.lua @@ -253,17 +253,20 @@ local function go_next(pos, velocity, stack) for _, vect in ipairs(can_go) do local npos = vector.add(pos, vect) local node = minetest.get_node(npos) - local tubedevice = minetest.get_item_group(node.name, "tubedevice") - local tube_def = minetest.registered_nodes[node.name].tube - local tube_priority = (tube_def and tube_def.priority) or 100 - if tubedevice > 0 and tube_priority >= max_priority then - if not tube_def or not tube_def.can_insert or - tube_def.can_insert(npos, node, stack, vect) then - if tube_priority > max_priority then - max_priority = tube_priority - next_positions = {} + local reg_node = minetest.registered_nodes[node.name] + if reg_node then + local tube_def = reg_node.tube + local tubedevice = minetest.get_item_group(node.name, "tubedevice") + local tube_priority = (tube_def and tube_def.priority) or 100 + if tubedevice > 0 and tube_priority >= max_priority then + if not tube_def or not tube_def.can_insert or + tube_def.can_insert(npos, node, stack, vect) then + if tube_priority > max_priority then + max_priority = tube_priority + next_positions = {} + end + next_positions[#next_positions + 1] = {pos = npos, vect = vect} end - next_positions[#next_positions + 1] = {pos = npos, vect = vect} end end end -- cgit v1.2.3