Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local home = vector.new(0,0,0)
- local wps = {}
- an.setSandboxBoundaries(-12,-8,-5,2,3,30)
- an.setSandboxAction("kill")
- function regWP(name,x,y,z,dir)
- wps[name] = {vector.new(x,y,z),dir}
- end
- function moveWP(wpN,moveOrder)
- an.goTo(an.localDelta(an.worldToLocal(wps[wpN][1])),moveOrder)
- if wps[wpN][2] ~= nil then
- an.turnDir(wps[wpN][2])
- end
- end
- function goHome()
- an.goTo(an.localDelta(an.worldToLocal(vector.new(0,0,0))),{"y","x","z"})
- an.turnDir(1)
- end
- function getRowOff()
- return math.abs(an.getLoc().x)
- end
- function getLayerOff()
- return 0
- end
- function blockAllowed(blockPos)
- if blockPos.x > 0 then return false end
- if blockPos.x < -8 then return false end
- if blockPos.z < 1 then return false end
- if blockPos.z > 18 then return false end
- if blockPos.y > -1 then return false end
- if blockPos.y < -5 then return false end
- if (math.abs(blockPos.x)-1) % 3 == 0 then
- --local cP = blockPos.z - 1
- if ( blockPos.z + 1 ) % 3 == 0 then
- return false
- end
- end
- return true
- end
- function getRowEnd(row)
- local row = row or getRowOff()
- local endC = 1
- if row % 2 == 0 then endC = 18 end
- return endC
- end
- function isEndOfRow()
- local endC = getRowEnd()
- return ( an.getLoc().z == endC )
- end
- function translatePos(delta)
- return an.getLoc() + delta
- end
- function tryBreak()
- if blockAllowed(translatePos(an.getVecMod())) then
- turtle.dig()
- end
- end
- function tryBreakDown()
- if blockAllowed(translatePos(vector.new(0,-1,0))) then
- turtle.digDown()
- end
- end
- function harvestRow()
- local layer = getLayerOff()
- local row = getRowOff()
- if row % 2 == 1 then
- an.turnDir(3)
- else
- an.turnDir(1)
- end
- while not isEndOfRow() do
- tryBreak()
- tryBreakDown()
- an.forward()
- print("CURN: "..textutils.serialize(an.getLoc()))
- end
- tryBreak()
- tryBreakDown()
- end
- function harvest()
- goHome()
- an.forward()
- while getRowOff() < 8 do
- harvestRow()
- local modX = -1
- local tarZ = getRowEnd(getRowOff())
- local cur = an.getLoc()
- cur.x = cur.x + modX
- cur.z = tarZ
- print("cur: " .. textutils.serialize(an.getLoc()))
- print("moving to: " ..textutils.serialize(cur))
- print("-----") read()
- an.goTo(an.localDelta(cur),{"y","x","z"})
- end
- end
- an.select(1)
- harvest()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement