diff --git a/src/main.lua b/src/main.lua index 0a8a2d3..4cb2c2d 100644 --- a/src/main.lua +++ b/src/main.lua @@ -612,12 +612,10 @@ local function VP_moveto(x,z, cx,cz,direction) return cx,cz,direction end local function VP_optimizestack(target) - -- go from top to bottom and erase false entries until we encounter a true one. - local index = #target + -- go from bottom to top and erase false entries until we encounter a true one. while #target > 0 do - if target[index] then break else - table.remove(target, index) - index = index - 1 + if target[1] then break else + table.remove(target, 1) end end @@ -719,7 +717,7 @@ local function VP_printstack(buf, dimensions, cx,cy,cz,direction) local tempbuf = buf["stacks"][posasstring(x,z)] if tempbuf then cx,cz,direction = VP_moveto(x,z, cx,cz,direction) - for _=1,buf["height"],1 do + for _=1,#tempbuf,1 do move("down", true) end for _,v in pairs(tempbuf) do