Advertisement
nerfnerf123

refuelGen

Jul 15th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.89 KB | None | 0 0
  1. local atGen=true
  2. local atChest=false
  3. minFuel=64
  4.  
  5. local function checkFuel()
  6.     if turtle.getFuelLevel() < minFuel then
  7.         print("Refueling!")
  8.         turtle.select(16)
  9.         while turtle.getFuelLevel() < minFuel do
  10.             turtle.refuel(1)
  11.             os.sleep(0.1)
  12.         end
  13.     else
  14.         print("Fuel sufficient!")
  15.     end
  16. end
  17.    
  18.  
  19. local function goToChest()
  20.     checkFuel()
  21.     if atGen==true then
  22.  
  23.         turtle.turnLeft()
  24.         turtle.turnLeft()
  25.   print("Starting first forward...")
  26.         os.sleep(1)
  27.         for i=1,28,1 do turtle.forward() end
  28.         os.sleep(1)
  29.   print("Turning right...")
  30.         turtle.turnRight()
  31.         os.sleep(1)
  32.   print("Starting second forward...")
  33.         for i=1,9,1 do turtle.forward() end
  34.         turtle.down()
  35.   print("Finished at chest!")
  36.         atGen=false
  37.         atChest=true
  38.     else
  39.         print("Error, already at chest or not at gen!")
  40.     end
  41. end
  42.  
  43. local function goToGen()
  44.     checkFuel()
  45.     if atChest==true then
  46.         turtle.up()
  47.         turtle.turnLeft()
  48.         turtle.turnLeft()
  49.   print("Starting first forward...")
  50.         os.sleep(1)
  51.         for i=1,9,1 do turtle.forward() end
  52.         os.sleep(1)
  53.   print("Turning left...")
  54.         turtle.turnLeft()
  55.         os.sleep(1)
  56.   print("Starting second forward...")
  57.         for i=1,28,1 do turtle.forward() end
  58.   print("Finished at gen!")
  59.         atChest=false
  60.         atGen=true
  61.     else
  62.         print("Error, already at gen or not at chest!")
  63.     end
  64. end
  65.  
  66. local turtleSuck=1
  67.  
  68. local function suckWood()
  69.     while true do
  70.         turtle.select(turtleSuck)
  71.         turtle.suck()
  72.         if turtle.suck()==false then
  73.             turtleSuck = turtleSuck+1
  74.         end
  75.         if turtleSuck==15 then
  76.             turtleSuck=1
  77.             return false
  78.         end
  79.     end
  80. end
  81.  
  82. local function dropWood()
  83.     print("Dropping wood!")
  84.     while true do
  85.         turtle.select(turtleSuck)
  86.         turtle.dropDown()
  87.         if turtle.dropDown()==false then
  88.             turtleSuck = turtleSuck+1
  89.         end
  90.         if turtleSuck==16 then
  91.             turtleSuck=1
  92.             return false
  93.         end
  94.     end
  95. end
  96.  
  97. goToChest()
  98. suckWood()
  99. goToGen()
  100. dropWood()
  101. print("RefuelGen finished!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement