forked from mtcontrib/pipeworks
Optimize sorting tube code a bit.
This commit is contained in:
parent
dad386b564
commit
9a83380b2b
30
tubes.lua
30
tubes.lua
|
@ -271,31 +271,29 @@ if pipeworks.enable_mese_tube then
|
||||||
fs_helpers.cycling_button(meta, "button[7,5;1,1", "l6s", {"Off", "On"})..
|
fs_helpers.cycling_button(meta, "button[7,5;1,1", "l6s", {"Off", "On"})..
|
||||||
"list[current_player;main;0,7;8,4;]")
|
"list[current_player;main;0,7;8,4;]")
|
||||||
end
|
end
|
||||||
|
local os_clock = os.clock
|
||||||
pipeworks.register_tube("pipeworks:mese_tube", "Sorting Pneumatic Tube Segment", mese_plain_textures, mese_noctr_textures,
|
pipeworks.register_tube("pipeworks:mese_tube", "Sorting Pneumatic Tube Segment", mese_plain_textures, mese_noctr_textures,
|
||||||
mese_end_textures, mese_short_texture, mese_inv_texture,
|
mese_end_textures, mese_short_texture, mese_inv_texture,
|
||||||
{tube = {can_go = function(pos, node, velocity, stack)
|
{tube = {can_go = function(pos, node, velocity, stack)
|
||||||
local tbl = {}
|
local tbl, tbln = {}, 0
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
local found = false
|
|
||||||
local name = stack:get_name()
|
local name = stack:get_name()
|
||||||
for i, vect in ipairs(pipeworks.meseadjlist) do
|
for i, vect in ipairs(pipeworks.meseadjlist) do
|
||||||
if meta:get_int("l"..tostring(i).."s") == 1 then
|
if meta:get_int("l"..i.."s") == 1 then
|
||||||
for _, st in ipairs(inv:get_list("line"..tostring(i))) do
|
local invname = "line"..i
|
||||||
if st:get_name() == name then
|
local is_empty = true
|
||||||
found = true
|
for _, st in ipairs(inv:get_list(invname)) do
|
||||||
table.insert(tbl, vect)
|
if not st:is_empty() then
|
||||||
break
|
is_empty = false
|
||||||
|
if st:get_name() == name then
|
||||||
|
return { vect }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
if is_empty then
|
||||||
end
|
tbln = tbln + 1
|
||||||
if found == false then
|
tbl[tbln] = vect
|
||||||
for i, vect in ipairs(pipeworks.meseadjlist) do
|
|
||||||
if meta:get_int("l"..tostring(i).."s") == 1 then
|
|
||||||
if inv:is_empty("line"..tostring(i)) then
|
|
||||||
table.insert(tbl, vect)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user