summaryrefslogtreecommitdiff
path: root/railcart/init.lua
diff options
context:
space:
mode:
authorstujones11 <stujones111@gmail.com>2016-01-23 17:10:53 +0000
committerstujones11 <stujones111@gmail.com>2016-01-23 17:10:53 +0000
commita23e20f05301849a7902c6b11c55e2a581b0831b (patch)
tree0f0c5cb5a6287b048b6a4943877f7a4f46ebb350 /railcart/init.lua
parent0e9a29ddfc38ce8c198be21bd9597a7d5f03a9d4 (diff)
Don't assume table index is equal to cart id
Diffstat (limited to 'railcart/init.lua')
-rw-r--r--railcart/init.lua5
1 files changed, 2 insertions, 3 deletions
diff --git a/railcart/init.lua b/railcart/init.lua
index 8d60051..07edea3 100644
--- a/railcart/init.lua
+++ b/railcart/init.lua
@@ -68,8 +68,7 @@ minetest.register_entity("railcart:cart_entity", {
if puncher:get_player_control().sneak then
if self.cart then
if self.cart.id then
- railcart.allcarts[self.cart.id] = nil
- railcart:save()
+ railcart:remove_cart(self.cart.id)
end
end
self.object:remove()
@@ -167,7 +166,7 @@ minetest.register_craftitem("railcart:cart", {
end
local cons = railtrack:get_connections(pos)
local cart = railcart.cart:new()
- cart.id = #railcart.allcarts + 1
+ cart.id = railcart:get_new_id()
cart.inv = railcart:create_detached_inventory(cart.id)
cart.pos = pos
cart.prev = vector.new(pos)