From b75e5474836cf7cf8410c0ffc324616451a6d27e Mon Sep 17 00:00:00 2001 From: Justus Wolff Date: Sun, 22 Feb 2026 20:57:59 +0100 Subject: [PATCH] remade splitstack. --- src/main.lua | 30 +++++++++--------------------- 1 file changed, 9 insertions(+), 21 deletions(-) diff --git a/src/main.lua b/src/main.lua index 61dbbac..72e4353 100644 --- a/src/main.lua +++ b/src/main.lua @@ -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