remade splitstack.

This commit is contained in:
Justus Wolff
2026-02-22 20:57:59 +01:00
parent 0c71102650
commit b75e547483

View File

@@ -660,35 +660,22 @@ local function VP_splitstack(_stack, x)
local sz = dimensions["z"]
local height = _stack["height"]
local stacks = {}
local unevenstack = {}
local stackmod = math.fmod(VP_lengthofdict(stack), x)
local stackdiv = math.floor(VP_lengthofdict(stack)/x)
if stackmod ~= 0 then
for tempstackindex=0,stackmod,1 do
unevenstack[posasstring(math.fmod(tempstackindex, sx),math.floor(tempstackindex/sx))] = stack[posasstring(math.fmod(tempstackindex, sx),math.floor(tempstackindex/sx))]
end
end
if stackdiv ~= 0 then
local eind = 0
local x2 = x
if stackmod ~= 0 then x2 = x - 1 end
for _=0,x2,1 do
local buf = {}
for stackind=eind,stackdiv+eind,1 do
buf[posasstring(math.fmod(stackind, sx),math.floor(stackind/sx))] = stack[posasstring(math.fmod(stackind, sx),math.floor(stackind/sx))]
end
local spliteverx = math.floor(VP_lengthofdict(stack)/x)
local ind = 0
local buf = {}
for i,v in pairs(stack) do
if ind == spliteverx then
table.insert(stacks, buf)
eind = eind + stackdiv
buf = {}
end
buf[i] = v
ind = ind + 1
end
local out = {
height=height,
stacks={}
}
if #unevenstack > 0 then table.insert(out["stacks"],unevenstack) end
for _,v in pairs(stacks) do
table.insert(out["stacks"],v)
end
@@ -743,6 +730,7 @@ local function VP_printstack(buf, dimensions, cx,cy,cz,direction)
for _=1,buf["height"],1 do
move("down")
end
center(direction, 0)
return cx,cz,direction
end
local function VP_calccost(stacks, height,sx,sz) -- calculate needed blocks