remade splitstack.
This commit is contained in:
28
src/main.lua
28
src/main.lua
@@ -660,35 +660,22 @@ local function VP_splitstack(_stack, x)
|
|||||||
local sz = dimensions["z"]
|
local sz = dimensions["z"]
|
||||||
local height = _stack["height"]
|
local height = _stack["height"]
|
||||||
local stacks = {}
|
local stacks = {}
|
||||||
local unevenstack = {}
|
local spliteverx = math.floor(VP_lengthofdict(stack)/x)
|
||||||
local stackmod = math.fmod(VP_lengthofdict(stack), x)
|
local ind = 0
|
||||||
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 = {}
|
local buf = {}
|
||||||
for stackind=eind,stackdiv+eind,1 do
|
for i,v in pairs(stack) do
|
||||||
buf[posasstring(math.fmod(stackind, sx),math.floor(stackind/sx))] = stack[posasstring(math.fmod(stackind, sx),math.floor(stackind/sx))]
|
if ind == spliteverx then
|
||||||
end
|
|
||||||
table.insert(stacks, buf)
|
table.insert(stacks, buf)
|
||||||
eind = eind + stackdiv
|
buf = {}
|
||||||
end
|
end
|
||||||
|
buf[i] = v
|
||||||
|
ind = ind + 1
|
||||||
end
|
end
|
||||||
|
|
||||||
local out = {
|
local out = {
|
||||||
height=height,
|
height=height,
|
||||||
stacks={}
|
stacks={}
|
||||||
}
|
}
|
||||||
if #unevenstack > 0 then table.insert(out["stacks"],unevenstack) end
|
|
||||||
for _,v in pairs(stacks) do
|
for _,v in pairs(stacks) do
|
||||||
table.insert(out["stacks"],v)
|
table.insert(out["stacks"],v)
|
||||||
end
|
end
|
||||||
@@ -743,6 +730,7 @@ local function VP_printstack(buf, dimensions, cx,cy,cz,direction)
|
|||||||
for _=1,buf["height"],1 do
|
for _=1,buf["height"],1 do
|
||||||
move("down")
|
move("down")
|
||||||
end
|
end
|
||||||
|
center(direction, 0)
|
||||||
return cx,cz,direction
|
return cx,cz,direction
|
||||||
end
|
end
|
||||||
local function VP_calccost(stacks, height,sx,sz) -- calculate needed blocks
|
local function VP_calccost(stacks, height,sx,sz) -- calculate needed blocks
|
||||||
|
|||||||
Reference in New Issue
Block a user