Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- cords = {}
- cords["x"] = 0
- cords["z"] = 0
- itemInfo = {}
- function distance()
- return cords["x"] + cords["z"]
- end
- function checkFuel()
- if turtle.getFuelLevel() < cords["x"] then
- for i = 1,16 do
- itemInfo = turtle.getItemDetail(i)
- if itemInfo["name"] == "minecraft:coal" then
- turtle.select(i)
- turtle.refuel(itemInfo["count"])
- end
- end
- end
- end
- function forward(blocksF)
- turtle.digDown()
- for repeats = 1,blocksF do
- checkFuel()
- turtle.dig()
- turtle.forward()
- turtle.digDown()
- turtle.digUp()
- logCordX(1)
- end
- end
- function back(blocksB)
- turtle.turnLeft()
- turtle.turnLeft()
- for repeats = 1,blocksB do
- turtle.dig()
- turtle.forward()
- if turtle.inspectUp() == "minecraft:chest" then
- print("Chest above")
- else
- turtle.digUp()
- end
- turtle.digDown()
- logCordX(-1)
- end
- turtle.turnLeft()
- turtle.turnLeft()
- end
- function logCordX(changeX)
- cords["x"] = cords["x"] + changeX
- end
- function right()
- turtle.turnRight()
- turtle.dig()
- turtle.forward()
- turtle.digUp()
- turtle.digDown()
- turtle.turnLeft()
- logCordZ(-1)
- end
- function left()
- turtle.turnLeft()
- turtle.dig()
- turtle.forward()
- turtle.digUp()
- turtle.digDown()
- turtle.turnRight()
- logCordZ(1)
- end
- function logCordZ(changeZ)
- cords["z"] = cords["z"] + changeZ
- end
- function sRight(blocksR)
- turtle.turnRight()
- for repeats = 1,blocksR do
- turtle.dig()
- turtle.forward()
- if turtle.inspectUp() == "minecraft:chest" then
- print("Chest above")
- else
- turtle.digUp()
- end
- turtle.digDown()
- logCordZ(-1)
- end
- turtle.turnLeft()
- end
- function sLeft(blocksL)
- turtle.turnLeft()
- for repeats = 1,blocksL do
- turtle.dig()
- turtle.forward()
- if turtle.inspectUp() == "minecraft:chest" then
- print("Chest above")
- else
- turtle.digUp()
- end
- turtle.digDown()
- logCordZ(1)
- end
- turtle.turnRight()
- end
- function goHome()
- if cords["x"] > 0 then
- back(cords["x"])
- elseif cords["x"] < 0 then
- Travelx = -1 * cords["x"]
- forward(Travelx)
- end
- if cords["z"] > 0 then
- sRight(cords["z"])
- elseif cords["z"] < 0 then
- Travelz = -1 * cords["z"]
- sLeft(Travelz)
- end
- for i = 1,16 do
- turtle.select(i)
- turtle.dropUp()
- end
- end
- function checkInv(row)
- for i = row,16 do
- turtle.select(i)
- if turtle.getItemDetail ~= nil then
- status = true
- end
- end
- if status then
- goHome()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement