fix concentrator bug
This commit is contained in:
parent
4fcf259445
commit
9cc6b93f58
@ -62,7 +62,7 @@ local names = networks.register_junction("techage:concentrator", 2/8, Boxes, Tub
|
|||||||
techage.register_node(names, {
|
techage.register_node(names, {
|
||||||
on_push_item = function(pos, in_dir, stack)
|
on_push_item = function(pos, in_dir, stack)
|
||||||
local push_dir = M(pos):get_int("push_dir")
|
local push_dir = M(pos):get_int("push_dir")
|
||||||
return techage.push_items(pos, push_dir, stack)
|
return techage.safe_push_items(pos, push_dir, stack)
|
||||||
end,
|
end,
|
||||||
is_pusher = true, -- is a pulling/pushing node
|
is_pusher = true, -- is a pulling/pushing node
|
||||||
})
|
})
|
||||||
@ -101,7 +101,7 @@ names = networks.register_junction("techage:ta4_concentrator", 2/8, Boxes, Tube,
|
|||||||
techage.register_node(names, {
|
techage.register_node(names, {
|
||||||
on_push_item = function(pos, in_dir, stack)
|
on_push_item = function(pos, in_dir, stack)
|
||||||
local push_dir = M(pos):get_int("push_dir")
|
local push_dir = M(pos):get_int("push_dir")
|
||||||
return techage.push_items(pos, push_dir, stack)
|
return techage.safe_push_items(pos, push_dir, stack)
|
||||||
end,
|
end,
|
||||||
is_pusher = true, -- is a pulling/pushing node
|
is_pusher = true, -- is a pulling/pushing node
|
||||||
})
|
})
|
||||||
|
@ -405,6 +405,31 @@ function techage.push_items(pos, out_dir, stack, idx)
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Check for recursion and too long distances
|
||||||
|
local start_pos
|
||||||
|
function techage.safe_push_items(pos, out_dir, stack, idx)
|
||||||
|
local mem = techage.get_mem(pos)
|
||||||
|
if not mem.pushing then
|
||||||
|
if not start_pos then
|
||||||
|
start_pos = pos
|
||||||
|
mem.pushing = true
|
||||||
|
local res = techage.push_items(pos, out_dir, stack, idx)
|
||||||
|
mem.pushing = nil
|
||||||
|
start_pos = nil
|
||||||
|
return res
|
||||||
|
else
|
||||||
|
local npos, in_dir, name = get_dest_node(pos, out_dir)
|
||||||
|
if vector.distance(start_pos, npos) < (Tube.max_tube_length or 100) then
|
||||||
|
mem.pushing = true
|
||||||
|
local res = techage.push_items(pos, out_dir, stack, idx)
|
||||||
|
mem.pushing = nil
|
||||||
|
return res
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
function techage.unpull_items(pos, out_dir, stack)
|
function techage.unpull_items(pos, out_dir, stack)
|
||||||
local npos, in_dir, name = get_dest_node(pos, out_dir)
|
local npos, in_dir, name = get_dest_node(pos, out_dir)
|
||||||
if npos and NodeDef[name] and NodeDef[name].on_unpull_item then
|
if npos and NodeDef[name] and NodeDef[name].on_unpull_item then
|
||||||
|
@ -60,20 +60,21 @@ local function any_node_changed(pos)
|
|||||||
nvm.num = #minetest.find_nodes_in_area(nvm.pos1, nvm.pos2, {"air"})
|
nvm.num = #minetest.find_nodes_in_area(nvm.pos1, nvm.pos2, {"air"})
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
local num = #minetest.find_nodes_in_area(nvm.pos1, nvm.pos2, {"air"})
|
local num1 = #minetest.find_nodes_in_area(nvm.pos1, nvm.pos2, {"air"})
|
||||||
|
local num2 = #minetest.find_nodes_in_area(nvm.pos1, nvm.pos2, {"ignore"})
|
||||||
|
|
||||||
if nvm.num ~= num then
|
if num2 == 0 and nvm.num ~= num1 then
|
||||||
if nvm.mode == 1 and num < nvm.num then
|
if nvm.mode == 1 and num1 < nvm.num then
|
||||||
nvm.num = num
|
nvm.num = num1
|
||||||
return true
|
return true
|
||||||
elseif nvm.mode == 2 and num > nvm.num then
|
elseif nvm.mode == 2 and num1 > nvm.num then
|
||||||
nvm.num = num
|
nvm.num = num1
|
||||||
return true
|
return true
|
||||||
elseif nvm.mode == 3 then
|
elseif nvm.mode == 3 then
|
||||||
nvm.num = num
|
nvm.num = num1
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
nvm.num = num
|
nvm.num = num1
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user