Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Sets up the dimensons and direction for the turtle to move. Fully completes farming and partially completes mining.
- --Only used for mining and farming.
- function SetupFarm()
- local width = 0
- local length = 0
- print("The route will go foward and right to form a square. If you need to rotate the turtle enter the number of turns (turns to the right) the turtle needs to be facing the right way. Enter 0 to skip.")
- while true do
- Input = read()
- print("Working...")
- if tonumber(Input) == nil
- then
- print("Not a valid input, please try again.")
- else
- for turns = 1, tonumber(Input) do
- turtle.turnLeft()
- end
- break
- end
- end
- print("Define how far foward you want the turtle to move.")
- while true do
- Input = read()
- if tonumber(Input) == nil
- then
- print("Not a valid input, please try again.")
- else
- length = tonumber(Input)
- break
- end
- end
- print("Define how far right you want the turtle to move.")
- while true do
- Input = read()
- if tonumber(Input) == nil
- then
- print("Not a valid input, please try again.")
- else
- width = tonumber(Input)
- break
- end
- end
- Farm(length - 1, width)
- end
- function Farm(length, width)
- for row = 1, width do
- turtle.refuel()
- local canmove = turtle.forward()
- turtle.suck()
- if canmove == false then
- print("Cannot move. Either something is blocking the way or fuel is needed. Type resume to resume trail")
- while canmove == false do
- canmove = turtle.forward()
- turtle.suck()
- end
- end
- for col = 1, length do
- canmove = turtle.forward()
- turtle.suck()
- if canmove == false then
- print("Cannot move. Either something is blocking the way or fuel is needed. Type resume to resume trail")
- while canmove == false do
- canmove = turtle.forward()
- turtle.suck()
- end
- end
- end
- if (row % 2 == 0 and row ~= width) then
- turtle.turnLeft()
- turtle.forward()
- turtle.turnLeft()
- elseif row ~= width then
- turtle.turnRight()
- turtle.forward()
- turtle.turnRight()
- end
- end
- if width % 2 == 1 then
- turtle.turnLeft()
- for row = 1, length do
- turtle.forward()
- end
- turtle.turnLeft()
- for col = 1, width do
- turtle.forward()
- end
- turtle.turnLeft()
- turtle.turnLeft()
- else
- turtle.turnRight()
- for col = 1, width do
- turtle.forward()
- end
- turtle.turnRight()
- end
- print("Resting...")
- sleep(20)
- end
- --Main
- print("Welcome to the turtle setup, where all your config needs can be found!\n\n")
- print("Choose a job from the list\n\n")
- print("1. farm\n2. mine\n3. fill")
- Input = read()
- if(Input == "farm" or Input == "1")
- then
- SetupFarm()
- elseif(Input == "mine" or Input == "2")
- then
- elseif(Input == "fill" or Input == "3")
- then
- else
- end
Add Comment
Please, Sign In to add comment