Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ready = false
- function saveRoutinePosition(action)
- dataFile = fs.open("Data", fs.exists("Data") and "a" or "w")
- dataFile.write(action)
- dataFile.close()
- end
- function readRoutine()
- dataFile = fs.open("Data", "r")
- return dataFile.readAll()
- end
- function refuel()
- if(turtle.getFuelLevel() < turtle.getFuelLimit/2) then
- turtle.select(1)
- turtle.refuel()
- end
- end
- function chestArea()
- for i = 5, 16 do
- turtle.select(i)
- turtle.dropDown()
- end
- turtle.select(4)
- while not turtle.compare() do
- turtle.turnRight()
- end
- turtle.select(1)
- turtle.suck(turtle.getItemSpace())
- turtle.select(4)
- turtle.suck(turtle.getItemSpace())
- turtle.turnRight()
- if not turtle.detect() then
- turtle.place()
- end
- turtle.turnRight()
- if not turtle.detect() then
- turtle.place()
- end
- refuel()
- if fs.exists("Data") then
- if readRoutine() == "checkWood" then
- ready = true
- end
- else
- ready = true
- end
- while true do
- while ready do
- --Dig wood
- turtle.select(2)
- if not turtle.compare() then
- saveRoutinePosition("checkWood")
- nTurn = 0;
- while not turtle.compare() do
- if nTurn == 4 then
- if not turtle.detectUp() then
- saveRoutinePosition("reset")
- while not turtle.detectDown do
- turtle.down()
- end
- saveRoutinePosition("chestArea")
- chestArea()
- break end
- end
- turtle.turnRight()
- nTurn = nTurn + 1;
- end
- else
- turtle.dig()
- turtle.turnRight()
- turtle.turnRight()
- turtle.dig()
- if turtle.digUp() then
- saveRoutinePosition("digUp")
- end
- turtle.up()
- saveRoutinePosition("checkWood")
- end
- if not ready and readRoutine() == "reset" then
- while not turtle.detectDown do
- turtle.down()
- end
- saveRoutinePosition("chestArea")
- chestArea()
- ready = true
- break end
- end
- if not ready and readRoutine() == "chestArea" then
- chestArea()
- ready = true
- break end
- end
- if not ready and readRoutine == "digUp" then
- turtle.up()
- ready = true
- break end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement