forked from mtcontrib/pipeworks
Try to fix some bugs that happen on server restart
This commit is contained in:
parent
d532e646f6
commit
99a902a8b8
@ -361,7 +361,8 @@ minetest.register_entity("pipeworks:tubed_item", {
|
||||
initial_sprite_basepos = {x = 0, y = 0},
|
||||
is_visible = false,
|
||||
start_pos = {},
|
||||
route={}
|
||||
route = {},
|
||||
removed = false
|
||||
},
|
||||
|
||||
itemstring = '',
|
||||
@ -399,7 +400,9 @@ minetest.register_entity("pipeworks:tubed_item", {
|
||||
end,
|
||||
|
||||
get_staticdata = function(self)
|
||||
if self.start_pos==nil then return end
|
||||
if self.start_pos == nil or self.removed then
|
||||
return
|
||||
end
|
||||
local velocity = self.object:getvelocity()
|
||||
self.object:setpos(self.start_pos)
|
||||
return minetest.serialize({
|
||||
@ -428,7 +431,16 @@ minetest.register_entity("pipeworks:tubed_item", {
|
||||
self:set_item(item.itemstring)
|
||||
end,
|
||||
|
||||
remove = function(self)
|
||||
self.object:remove()
|
||||
self.removed = true
|
||||
self.itemstring = ''
|
||||
end,
|
||||
|
||||
on_step = function(self, dtime)
|
||||
if self.removed then
|
||||
return
|
||||
end
|
||||
if self.start_pos == nil then
|
||||
local pos = self.object:getpos()
|
||||
self.start_pos = roundpos(pos)
|
||||
@ -481,7 +493,7 @@ minetest.register_entity("pipeworks:tubed_item", {
|
||||
leftover = stack
|
||||
end
|
||||
if leftover:is_empty() then
|
||||
self.object:remove()
|
||||
self:remove()
|
||||
return
|
||||
end
|
||||
velocity.x = -velocity.x
|
||||
@ -497,7 +509,7 @@ minetest.register_entity("pipeworks:tubed_item", {
|
||||
drop_pos = minetest.find_node_near(vector.add(self.start_pos, velocity), 1, "air")
|
||||
if drop_pos then
|
||||
minetest.item_drop(stack, "", drop_pos)
|
||||
self.object:remove()
|
||||
self:remove()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user