Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rednet.open("right")
- jobAv = true
- manager = 5
- xCoord = 238
- yCoord = 77
- zCoord = 492
- xHome = xCoord
- yHome = yCoord
- zHome = zCoord
- oHome = "south"
- xQuarry = 999
- yQuarry = 999
- zQuarry = 999
- xProg = 999
- yProg = 999
- zProg = 999
- oProg = 1
- yMin = 999
- orient = 3
- orients = {"south","west","north","east"}
- zDiff = {1, 0, -1, 0}
- xDiff = {0, -1, 0, 1}
- lineLength = 8
- lines = 9
- function getFuel()
- fuel = turtle.getFuelLevel() < 150
- return fuel
- end
- function invFull()
- turtle.select(16)
- full = turtle.getItemCount() > 0
- turtle.select(1)
- return full
- end
- function forward()
- xCoord = xCoord + xDiff[orient]
- zCoord = zCoord + zDiff[orient]
- moved = false
- while not moved do
- turtle.dig()
- moved = turtle.forward()
- end
- end
- function left()
- orient = orient - 1
- orient = (orient - 1) % 4
- orient = orient + 1
- turtle.turnLeft()
- end
- function right()
- orient = orient - 1
- orient = (orient + 1) % 4
- orient = orient + 1
- turtle.turnRight()
- end
- function up()
- yCoord = yCoord + 1
- turtle.digUp()
- moved = false
- while not(moved) do
- moved = turtle.up()
- end
- end
- function down()
- yCoord = yCoord - 1
- turtle.digDown()
- moved = false
- while not(moved) do
- moved = turtle.down()
- end
- if yMin < yCoord then
- yMin = yCoord
- end
- end
- function look(dir)
- while dir ~= orients[orient] do
- right()
- end
- end
- function goto(xTarget, yTarget, zTarget, travel)
- if travel ~= 0 then
- while 95 > yCoord do
- up()
- end
- end
- if xTarget < xCoord then
- look("west")
- while xTarget < xCoord do
- forward()
- end
- end
- if xTarget > xCoord then
- look("east")
- while xTarget > xCoord do
- forward()
- end
- end
- if zTarget < zCoord then
- look("north")
- while zTarget < zCoord do
- forward()
- end
- end
- if zTarget > zCoord then
- look("south")
- while zTarget > zCoord do
- forward()
- end
- end
- while yTarget < yCoord do
- down()
- end
- while yTarget > yCoord do
- up()
- end
- end
- function returnItems()
- xProg = xCoord
- yProg = yCoord
- zProg = zCoord
- oProg = orient
- goto(xHome, yHome, zHome)
- look(oHome)
- for i = 1,16 do
- turtle.select(i)
- turtle.drop(64)
- end
- turtle.select(1)
- goto(xProg, yProg, zProg)
- look(orients[oProg])
- end
- function digLine()
- for i = 1,lineLength do
- if invFull() then
- returnItems()
- end
- if getFuel() then
- goto(xHome, yHome, zHome)
- term.clear()
- print("I Need Fuel")
- break
- end
- forward()
- end
- end
- function digLayer()
- qOrient = orient
- for i = 1,lines do
- digLine()
- if (i%2) == 1 and i < lines then
- right()
- forward()
- right()
- elseif i < lines then
- left()
- forward()
- left()
- end
- end
- goto(xQuarry, yCoord, zQuarry, 0)
- while orient ~= qOrient do
- right()
- end
- down()
- end
- function digQuarry(xTarget, yTarget, zTarget)
- xQuarry = xTarget
- yQuarry = yTarget
- zQuarry = zTarget
- goto(xQuarry, yQuarry, zQuarry)
- look("south")
- while yMin > 7 do
- digLayer()
- end
- goto(xQuarry, yQuarry, zQuarry)
- yMin = 999
- end
- function getJob()
- while jobAv do
- rednet.send(manager, "getJob")
- id, msg, dis = rednet.receive()
- if msg == "yes" then
- id, xQuarry, dis = rednet.receive()
- id, yQuarry, dis = rednet.receive()
- id, zQuarry, dis = rednet.receive()
- digQuarry(xQuarry, yQuarry, zQuarry)
- elseif msg == "no" then
- jobAv = false
- end
- end
- end
- while true do
- getJob()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement