Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local col = 0
- local row = 0
- local function loadsettings()
- file = io.open("settings.txt", "r")
- while true do
- line = file:read()
- if line == nil then break end
- col = tonumber(line)
- line = file:read()
- if line == nil then break end
- row = tonumber(line)
- file:close()
- return true
- end
- file:close()
- return false
- end
- local function createsettings()
- term.clear()
- term.setCursorPos(1,1)
- print("Please select your settings:")
- write("Number of columns: ")
- col = tonumber(read())
- write("Number of rows: ")
- row = tonumber(read())
- file = io.open("settings.txt", "w")
- file:write(col)
- file:write("\n")
- file:write(row)
- file:write("\n")
- file:close()
- term.clear()
- term.setCursorPos(1,1)
- print("Ready to harvest")
- end
- if fs.exists("settings.txt") then
- if not loadsettings() then
- createsettings()
- end
- term.clear()
- term.setCursorPos(1,1)
- print("Ready to harvest")
- else
- createsettings()
- end
- function rturn()
- turtle.turnRight()
- turtle.forward()
- turtle.forward()
- turtle.forward()
- turtle.forward()
- turtle.turnRight()
- end
- function lturn()
- turtle.turnLeft()
- turtle.forward()
- turtle.forward()
- turtle.forward()
- turtle.forward()
- turtle.turnLeft()
- end
- function chop()
- turtle.dig()
- turtle.forward()
- turtle.digDown()
- turtle.select(1)
- turtle.placeDown()
- turtle.select(2)
- count = 0
- while turtle.compareUp() do
- turtle.digUp()
- turtle.up()
- count = count + 1
- end
- for i=0,count do
- turtle.down()
- end
- turtle.forward()
- turtle.select(2)
- end
- function move()
- turtle.forward()
- turtle.forward()
- turtle.forward()
- end
- function check()
- if turtle.compare() then
- chop()
- else
- turtle.forward()
- end
- end
- -- used to check how to return to start position
- lastturn = "l"
- -- Call a refuel before moving
- turtle.select(16)
- turtle.refuel(10)
- turtle.select(2)
- -- First move called outside loop so turtle can turn outside the farm in loop
- for i = 1,col do
- move()
- for j = 1,row do
- check()
- move()
- end
- if lastturn == "l" then
- rturn()
- lastturn = "r"
- elseif lastturn == "r" then
- lturn()
- lastturn = "l"
- end
- end
- if lastturn == "l" then
- turtle.turnLeft()
- for k = 1,col do
- move()
- turtle.forward()
- end
- turtle.turnRight()
- elseif lastturn == "r" then
- for g =0,row do
- move()
- turtle.forward()
- end
- turtle.turnRight()
- for h = 1,col do
- move()
- turtle.forward()
- end
- turtle.turnRight()
- end
- turtle.select(2)
- slots = turtle.getItemCount()
- turtle.dropDown(slots - 1)
- turtle.select(3)
- turtle.dropDown()
- turtle.select(4)
- turtle.dropDown()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement