goldminer127

turtle

Sep 4th, 2021 (edited)
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.49 KB | None | 0 0
  1. --Sets up the dimensons and direction for the turtle to move. Fully completes farming and partially completes mining.
  2. --Only used for mining and farming.
  3. function SetupFarm()
  4.         local width = 0
  5.         local length = 0
  6.         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.")
  7.         while true do
  8.             Input = read()
  9.             print("Working...")
  10.             if tonumber(Input) == nil
  11.             then
  12.                 print("Not a valid input, please try again.")
  13.             else
  14.                 for turns = 1, tonumber(Input) do
  15.                     turtle.turnLeft()
  16.                 end
  17.                 break
  18.             end
  19.         end
  20.         print("Define how far foward you want the turtle to move.")
  21.         while true do
  22.             Input = read()
  23.             if tonumber(Input) == nil
  24.             then
  25.                 print("Not a valid input, please try again.")
  26.             else
  27.                 length = tonumber(Input)
  28.                 break
  29.             end
  30.         end
  31.         print("Define how far right you want the turtle to move.")
  32.         while true do
  33.             Input = read()
  34.             if tonumber(Input) == nil
  35.             then
  36.                 print("Not a valid input, please try again.")
  37.             else
  38.                 width = tonumber(Input)
  39.                 break
  40.             end
  41.         end
  42.     Farm(length - 1, width)
  43. end
  44.  
  45. function Farm(length, width)
  46.     for row = 1, width do
  47.         turtle.refuel()
  48.         local canmove = turtle.forward()
  49.         turtle.suck()
  50.         if canmove == false then
  51.             print("Cannot move. Either something is blocking the way or fuel is needed. Type resume to resume trail")
  52.             while canmove == false do
  53.                 canmove = turtle.forward()
  54.                 turtle.suck()
  55.             end
  56.         end
  57.         for col = 1, length do
  58.             canmove = turtle.forward()
  59.             turtle.suck()
  60.             if canmove == false then
  61.                 print("Cannot move. Either something is blocking the way or fuel is needed. Type resume to resume trail")
  62.                 while canmove == false do
  63.                     canmove = turtle.forward()
  64.                     turtle.suck()
  65.                 end
  66.             end
  67.         end
  68.         if (row % 2 == 0 and row ~= width) then
  69.             turtle.turnLeft()
  70.             turtle.forward()
  71.             turtle.turnLeft()
  72.         elseif row ~= width then
  73.             turtle.turnRight()
  74.             turtle.forward()
  75.             turtle.turnRight()
  76.         end
  77.     end
  78.     if width % 2 == 1 then
  79.         turtle.turnLeft()
  80.         for row = 1, length do
  81.             turtle.forward()
  82.         end
  83.         turtle.turnLeft()
  84.         for col = 1, width do
  85.             turtle.forward()
  86.         end
  87.         turtle.turnLeft()
  88.         turtle.turnLeft()
  89.     else
  90.         turtle.turnRight()
  91.         for col = 1, width do
  92.             turtle.forward()
  93.         end
  94.         turtle.turnRight()
  95.     end
  96.     print("Resting...")
  97.     sleep(20)
  98. end
  99. --Main
  100. print("Welcome to the turtle setup, where all your config needs can be found!\n\n")
  101. print("Choose a job from the list\n\n")
  102. print("1. farm\n2. mine\n3. fill")
  103. Input = read()
  104. if(Input == "farm" or Input == "1")
  105. then
  106.     SetupFarm()
  107. elseif(Input == "mine" or Input == "2")
  108. then
  109.    
  110. elseif(Input == "fill" or Input == "3")
  111. then
  112.  
  113. else
  114.  
  115. end
Add Comment
Please, Sign In to add comment