Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --start: -275 69 351
- --farm: -257 72 385
- raise = 10
- farmLength = 13
- lane = 7
- shell.run("clear")
- print("Searching for location...")
- --x, y, z = gps.locate(10)
- x = nil
- shell.run("clear")
- if x == nil then
- print("Search failed.. Reverting to manual input.")
- write("X: ")
- x = read()
- write("Y: ")
- y = read()
- write("Z: ")
- z = read()
- else
- print("Location retrieved!")
- end
- write("Direction: ")
- direction = read()
- print("")
- print("Specify destination..")
- write("X: ")
- xGo = read()
- write("Y: ")
- yGo = read()
- write("Z: ")
- zGo = read()
- write("Direction: ")
- dGo = read()
- function vertical(dir,amount)
- repeat
- if dir == 1 then
- turtle.up()
- else
- turtle.down()
- end
- amount = amount - 1
- until amount == 0
- end
- function switchLane(dir)
- if dir == "right" then
- turtle.turnRight()
- turtle.forward()
- turtle.turnRight()
- elseif dir == "left" then
- turtle.turnLeft()
- turtle.forward()
- turtle.turnLeft()
- end
- end
- function farmIt(forward)
- turtle.select(1)
- turtle.digDown()
- turtle.select(2)
- turtle.placeDown()
- if forward then
- turtle.forward()
- end
- end
- function go(amount)
- repeat
- amount = amount - 1
- turtle.forward()
- until amount == 0
- end
- function placeIn(slot)
- turtle.suck()
- amount = turtle.getItemCount(slot)
- turtle.drop(amount-1)
- end
- function face(num)
- while direction ~= num do
- if direction == 3 then
- direction = 0
- else
- direction = direction + 1
- end
- turtle.turnRight()
- end
- end
- function goto(x1,y1,z1,f)
- vertical(1,raise)
- if x1 > x then
- face(3)
- go(x1-x)
- end
- if x1 < x then
- face(1)
- go(x-x1)
- end
- if z1 > z then
- face(0)
- go(z1-z)
- end
- if z1 < z then
- face(2)
- go(z-z1)
- end
- vertical(0,raise)
- --if y1 > y then
- --vertical(1,y1-y)
- --end
- --if y1 < y then
- --vertical(0,y-y1)
- --end
- face(f)
- x = x1
- y = y1
- z = z1
- direction = f
- end
- function farm(direc, last)
- amount = farmLength-1
- repeat
- farmIt(true)
- amount = amount - 1
- until amount == 0
- farmIt(false)
- if not last then
- if direc == "right" then
- switchLane("right")
- elseif direc == "left" then
- switchLane("left")
- end
- end
- end
- function completeFarm(lanes)
- turn = "right"
- for x=1,lanes do
- if x == lanes then
- farm(turn, true)
- else
- farm(turn, false)
- end
- if turn == "right" then
- turn = "left"
- elseif turn == "left" then
- turn = "right"
- end
- end
- end
- goto(xGo,yGo,zGo,dGo)
- print("Press any key to launch..")
- repeat
- local event = os.pullEvent()
- until event == "key"
- x = -263
- y = 72
- z = 397
- direction = 0
- xGo = -275
- yGo = 69
- zGo = 351
- dGo = 2
- goto(xGo,yGo,zGo,dGo)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement