diff --git a/baselib.lua b/baselib.lua index a746ca3..53bd7ad 100644 --- a/baselib.lua +++ b/baselib.lua @@ -259,7 +259,9 @@ function minecart.add_nodecart(pos, node_name, param2, cargo, owner, userID) -- If no rail is around, use an available cart as new search center pos2 = minetest.find_node_near(pos, 1, minecart.lRailsExt) -- ...and search again. - pos2 = minetest.find_node_near(pos2, 1, minecart.lRails) + if pos2 then + pos2 = minetest.find_node_near(pos2, 1, minecart.lRails) + end end else pos2 = vector.new(pos) diff --git a/monitoring.lua b/monitoring.lua index 2956f88..82e3b03 100644 --- a/monitoring.lua +++ b/monitoring.lua @@ -213,7 +213,9 @@ function minecart.monitoring_remove_cart(owner, userID) if tCartsOnRail[owner] and tCartsOnRail[owner][userID] then -- Cart stopped? if tCartsOnRail[owner][userID].objID == 0 then - -- Can directly be deleted + -- Mark as "to be deleted" by monitoring (if part of monitoring) + tCartsOnRail[owner][userID].objID = nil + -- And delete directly in addition tCartsOnRail[owner][userID] = nil else -- Cart running -- Mark as "to be deleted" by monitoring @@ -292,7 +294,7 @@ minetest.register_chatcommand("stopcart", { minecart.remove_entity(entity, data.pos) else -- Cart as zombie/invalid/corrupted - -- nothing to do + minetest.log("warning", "[Minecart] data.objID ~= 0, but no entity available!") end minetest.add_item(player_pos, ItemStack({name = data.node_name})) minecart.monitoring_remove_cart(owner, userID) diff --git a/storage.lua b/storage.lua index 54f7a48..1ac383f 100644 --- a/storage.lua +++ b/storage.lua @@ -57,8 +57,8 @@ minetest.register_on_mods_loaded(function() -- mark all entity carts as zombified if cart.objID ~= 0 then cart.objID = -1 - minecart.push(1, cart) end + minecart.push(1, cart) end end end