Optimize table inserting
This commit is contained in:
parent
f1a50fdd9a
commit
df80f18f90
@ -98,7 +98,7 @@ function worktable.dig(pos, _)
|
|||||||
|
|
||||||
if not inv:is_empty("input") or not inv:is_empty("forms") or not
|
if not inv:is_empty("input") or not inv:is_empty("forms") or not
|
||||||
inv:is_empty("hammer") or not inv:is_empty("tool") or not
|
inv:is_empty("hammer") or not inv:is_empty("tool") or not
|
||||||
inv:is_empty("storage") or not inv:is_empty("craft") then
|
inv:is_empty("storage") then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
@ -146,7 +146,7 @@ local function update_form_inventory(inv, input_stack)
|
|||||||
local form_name = form[1]
|
local form_name = form[1]
|
||||||
|
|
||||||
local count = math.min(worktable.anz(form_name) * inv:get_stack("input", 1):get_count(), input_stack:get_stack_max())
|
local count = math.min(worktable.anz(form_name) * inv:get_stack("input", 1):get_count(), input_stack:get_stack_max())
|
||||||
table.insert(form_inv_list, string.format("xdecor:%s_%s %d", form_name, material_name, count))
|
form_inv_list[#form_inv_list+1] = string.format("xdecor:%s_%s %d", form_name, material_name, count)
|
||||||
end
|
end
|
||||||
inv:set_list("forms", form_inv_list)
|
inv:set_list("forms", form_inv_list)
|
||||||
end
|
end
|
||||||
|
30
xwall.lua
30
xwall.lua
@ -104,33 +104,33 @@ function xwall.construct_node_box_data(node_box_list, center_node_box_list, node
|
|||||||
res.c0, res.c1, res.c2, res.c3, res.c4 = {}, {}, {}, {}, {}
|
res.c0, res.c1, res.c2, res.c3, res.c4 = {}, {}, {}, {}, {}
|
||||||
|
|
||||||
for _, v in pairs(node_box_list) do
|
for _, v in pairs(node_box_list) do
|
||||||
table.insert(res.c1, v)
|
res.c1[#res.c1+1] = v
|
||||||
table.insert(res.c2, v)
|
res.c2[#res.c2+1] = v
|
||||||
table.insert(res.c3, v)
|
res.c3[#res.c3+1] = v
|
||||||
table.insert(res.c4, v)
|
res.c4[#res.c4+1] = v
|
||||||
end
|
end
|
||||||
|
|
||||||
for _, v in pairs(node_box_list) do
|
for _, v in pairs(node_box_list) do
|
||||||
table.insert(res.c2, {v[3], v[2], v[1], v[6], v[5], v[4]})
|
res.c2[#res.c2+1] = {v[3], v[2], v[1], v[6], v[5], v[4]}
|
||||||
table.insert(res.c3, {v[3], v[2], v[1], v[6], v[5], v[4]})
|
res.c3[#res.c3+1] = {v[3], v[2], v[1], v[6], v[5], v[4]}
|
||||||
table.insert(res.c4, {v[3], v[2], v[1], v[6], v[5], v[4]})
|
res.c4[#res.c4+1] = {v[3], v[2], v[1], v[6], v[5], v[4]}
|
||||||
end
|
end
|
||||||
|
|
||||||
for _, v in pairs(node_box_list) do
|
for _, v in pairs(node_box_list) do
|
||||||
table.insert(res.c3, {v[4], v[2], v[3]-0.5, v[1], v[5], v[6]-0.5})
|
res.c3[#res.c3+1] = {v[4], v[2], v[3]-0.5, v[1], v[5], v[6]-0.5}
|
||||||
table.insert(res.c4, {v[4], v[2], v[3]-0.5, v[1], v[5], v[6]-0.5})
|
res.c4[#res.c4+1] = {v[4], v[2], v[3]-0.5, v[1], v[5], v[6]-0.5}
|
||||||
end
|
end
|
||||||
|
|
||||||
for _, v in pairs(node_box_list) do
|
for _, v in pairs(node_box_list) do
|
||||||
table.insert(res.c4, {v[3]-0.5, v[2], v[4], v[6]-0.5, v[5], v[1]})
|
res.c4[#res.c4+1] = {v[3]-0.5, v[2], v[4], v[6]-0.5, v[5], v[1]}
|
||||||
end
|
end
|
||||||
|
|
||||||
for _, v in pairs(center_node_box_list) do
|
for _, v in pairs(center_node_box_list) do
|
||||||
table.insert(res.c0, v)
|
res.c0[#res.c0+1] = v
|
||||||
table.insert(res.c1, v)
|
res.c1[#res.c1+1] = v
|
||||||
table.insert(res.c2, v)
|
res.c2[#res.c2+1] = v
|
||||||
table.insert(res.c3, v)
|
res.c3[#res.c3+1] = v
|
||||||
table.insert(res.c4, v)
|
res.c4[#res.c4+1] = v
|
||||||
end
|
end
|
||||||
|
|
||||||
if #res.c0 < 1 then res.c0 = nil end
|
if #res.c0 < 1 then res.c0 = nil end
|
||||||
|
Loading…
Reference in New Issue
Block a user