Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local version = 1.0
- local filename = "farm"
- local paste = "yg4au0jZ"
- local function update()
- local url = "http://pastebin.com/raw.php?i="..paste
- local temp = http.get(url)
- local ver = temp.readLine()
- if tonumber(string.sub(ver, 17)) ~= version then
- fs.delete(filename)
- shell.run("pastebin get "..paste.." "..filename)
- shell.run(filename)
- return true
- end
- return false
- end
- local test = update()
- if test == true then
- error()
- end
- local raise = 10
- local farmLength = 35
- local lane = 5
- local direction = 0
- local x = nil
- local y = nil
- local z = nil
- local fCoords = {}
- local sCoords = {}
- local cCoords = {}
- x, y, z = gps.locate(10)
- local function getDir()
- if not fs.exists("Direction") then
- write("Firsttime direction entry: ")
- direction = read()
- local dir = fs.open("Direction","w")
- dir.writeLine(direction)
- dir.close()
- else
- local dir = fs.open("Direction","r")
- direction = tonumber(dir.readLine())
- dir.close()
- end
- end
- local saveDir()
- local dir = fs.open("Direction","w")
- dir.writeLine(direction)
- dir.close()
- end
- local function editData()
- getDir()
- if not fs.exists("FarmLoc") then
- shell.run("clear")
- print("Determining farm starting coordinates..")
- fCoords = gps.locate(10)
- print("Farm start = "..x..", "..y..", "..z)
- local dir = fs.open("FarmLoc","w")
- dir.writeLine(x)
- dir.writeLine(y)
- dir.writeLine(z)
- dir.close()
- else
- local dir = fs.open("FarmLoc","r")
- fCoords[1] = tonumber(dir.readLine())
- fCoords[2] = tonumber(dir.readLine())
- fCoords[3] = tonumber(dir.readLine())
- dir.close()
- end
- local dir2 = fs.open("seedChest","r")
- sCoords[1] = tonumber(dir.readLine())
- sCoords[2] = tonumber(dir.readLine())
- sCoords[3] = tonumber(dir.readLine())
- dir.close()
- local dir3 = fs.open("cropChest","r")
- cCoords[1] = tonumber(dir.readLine())
- cCoords[2] = tonumber(dir.readLine())
- cCoords[3] = tonumber(dir.readLine())
- dir.close()
- end
- 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
- face(direction+1)
- turtle.forward()
- face(direction+1)
- elseif dir == "left" then
- face(direction-1)
- turtle.forward()
- face(direction-1)
- 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
- saveDir()
- 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
- 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