Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local stop = 0
- local fuellevel = 0
- local ox, oy, oz = nil, nil, nil
- cx, cy, cz = nil, nil, nil
- local turned = 0
- -- local x, y, z = nil, nil, nil
- direct = 0
- rednet.open("right")
- ox, oy, oz = gps.locate(3)
- function doit()
- fuellevel = turtle.getFuelLevel()
- print("fuellevel = "..fuellevel)
- if fuellevel == 0 then
- print("Please put fuel in slot1.")
- while fuellevel == 0 do
- turtle.refuel()
- fuellevel = turtle.getFuelLevel()
- os.sleep(1)
- end
- print("Thank you :D")
- end
- end
- function finddirect1()
- if not turtle.forward() then
- if turned ~= 3 then
- turtle.turnRight()
- turned = turned + 1
- finddirect1()
- else
- print("I need space in front of me!")
- end
- else
- finddirect2()
- end
- end
- function finddirect2()
- cx, cy, cz = gps.locate(3)
- if cx and cy and cz then
- if cx < ox then
- direct = 3
- end
- if cx > ox then
- direct = 1
- end
- if cz < oz then
- direct = 4
- end
- if cz > oz then
- direct = 2
- end
- else
- print("fail")
- end
- end
- if ox and oy and oz then
- print(ox..", "..oy..", "..oz)
- doit()
- finddirect1()
- if stop == 0 then
- print(""..direct)
- end
- cx, cy, cz = gps.locate(3)
- else
- print("Couldn't get position")
- end
Advertisement
Add Comment
Please, Sign In to add comment