Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Script by zortag - The turtle reach the starting position from everywhere and face correctly, farm a 5x5 field then drop in a
- -- chest, come back to starting point, check fuel and refuel if needed. The script automatically skips useless steps
- -- This script needs this other script to work pastebin.com/UYfrBtbj named "moveto"
- -- This script needs a GPS tower (www.computercraft.info/forums2/index.php?/topic/3088-how-to-guide-gps-global-position-system/)
- -- It is better to configure the GPS tower coordinates with the real position where computers are, so it is easier configure the
- -- turtle starting point using real coordinates. Rename the script "startup" (it auto resume from averywhere)
- -- The turtle needs an hoe and a wireless modem installed
- -- You have to configure the coordinates for the turtle (press F3 and use feet position):
- -- Starting point: line 123
- -- Align point: line 124 (same as starting coordinates but +2 at the facing axis)
- -- Starting point check: line 195 (same as starting point, be sure axis are correct)
- -- Field design (image at i.imgur.com/hvtTQNV.jpg)
- -- H = dirt, W = water, S = starting point, D = drop point
- -- fuel pickup is 1 block under the starting position (can be a chest under the turtle)
- -- drop chest is at the same level the turtle is
- --
- -- HHHHH
- -- HHHHH
- -- HHWHH
- -- HHHHH
- -- HHHHH
- -- S
- -- |
- -- +---D
- function dig()
- turtle.digDown()
- turtle.forward()
- turtle.digDown()
- turtle.forward()
- turtle.digDown()
- turtle.forward()
- turtle.digDown()
- turtle.forward()
- turtle.digDown()
- end
- function left()
- turtle.turnLeft()
- turtle.forward()
- turtle.turnLeft()
- end
- function right()
- turtle.turnRight()
- turtle.forward()
- turtle.turnRight()
- end
- function left2()
- turtle.turnLeft()
- turtle.turnLeft()
- end
- function place()
- turtle.select(1)
- turtle.placeDown()
- turtle.forward()
- turtle.placeDown()
- turtle.forward()
- turtle.placeDown()
- turtle.forward()
- turtle.placeDown()
- turtle.forward()
- turtle.placeDown()
- end
- function fuel()
- term.setCursorPos(1, 1)
- write("Fuel left ")
- write(turtle.getFuelLevel())
- end
- function eat()
- if turtle.getFuelLevel() < 1000 then
- term.clear()
- term.setCursorPos(1, 1)
- print("Refuelling...")
- turtle.select(16)
- turtle.suckDown()
- turtle.refuel()
- term.clear()
- term.setCursorPos(1, 1)
- print("Done!")
- sleep(2)
- else
- term.clear()
- term.setCursorPos(1, 1)
- print("I'm fine, let's go working!")
- sleep(2)
- end
- end
- function sleeping()
- local w = 0
- while w <= 40 do
- if w == 0 then
- term.clear()
- term.setCursorPos(1, 1)
- fuel()
- term.setCursorPos(1, 2)
- print("Waiting 40 minutes")
- sleep(60)
- w = w + 1
- elseif w ==40 then
- print("Restarting...")
- sleep(2)
- break
- else
- term.setCursorPos(1, 1)
- fuel()
- term.setCursorPos(1, 3)
- print(w, " minutes passed")
- sleep(60)
- w = w + 1
- end
- end
- end
- function gohome()
- term.clear()
- write("Positioning...")
- shell.run("moveto", 335,66,15)
- shell.run("moveto", 335,66,13)
- turtle.back()
- turtle.back()
- turtle.down()
- term.setCursorPos(1,2)
- term.write("I'm at home")
- sleep(2)
- end
- function job()
- term.clear()
- fuel()
- term.setCursorPos(1, 2)
- write("Farming...")
- turtle.select(1)
- turtle.up()
- turtle.forward()
- dig()
- left()
- dig()
- right()
- dig()
- left()
- dig()
- right()
- dig()
- left2()
- place()
- left()
- place()
- right()
- place()
- left()
- place()
- right()
- place()
- turtle.forward()
- turtle.forward()
- turtle.forward()
- turtle.turnLeft()
- turtle.forward()
- turtle.forward()
- turtle.forward()
- turtle.forward()
- term.clear()
- fuel()
- term.setCursorPos(1, 2)
- write("Dropping...")
- function dropItems()
- for slot = 2, 15 do
- turtle.select(slot)
- turtle.dropDown()
- end
- end
- dropItems()
- left2()
- turtle.forward()
- turtle.forward()
- turtle.forward()
- turtle.forward()
- turtle.turnRight()
- turtle.forward()
- turtle.forward()
- turtle.down()
- sleeping()
- end
- while true do
- local x, y, z = gps.locate(5)
- if x == 335 and y == 65 and z == 15 then
- job()
- else
- gohome()
- end
- eat()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement