-- like cube, but uses pathfinding local mv = require("movement") local pathfind = require("pathfind") local function obstacle(node) if node.z < 0 and node.z > -10 and node.x < 10 and node.x > -10 then return true end if node.x <= 0 and node.x > -10 and node.y < 5 and node.y > -5 and node.z < 10 then return true end return pathfind.obstacle.stone(node) end local function moveTo(offset) pathfind.forcePath(offset, obstacle) end local function dropStuffOff() local prev_pos,prev_face = mv.getPosition() moveTo(vector.new(0,0,0)) mv.face(0, -1) mv.dumpInventory() moveTo(prev_pos) mv.face(prev_face.x, prev_face.z) end local function callback() if mv.isInventoryFull() then dropStuffOff() end end local function digCube(depth, height, width) if height < 3 or width <= 0 or depth <= 0 then print("sorry, your cube is too small") return end pathfind.addExclusionZone(vector.new(-1,-5,-5), vector.new(-5,5,5)) -- todo: don't hardcode the offset local offset = vector.new(-2 - depth, -78, 0) pathfind.cube(offset, depth, height, width, obstacle, callback) dropStuffOff() moveTo(vector.new(0,0,0)) mv.face(1,0) end local function main(args) if #args == 0 then digCube(60,9,60) elseif #args == 1 then local n = tonumber(args[1]) digCube(n,n,n) elseif #args == 3 then digCube(tonumber(args[1]), tonumber(args[2]), tonumber(args[3])) else print("usage: quarry [depth] [height] [width]") print("got the wrong number of args...") end end local args = {...} main(args)