Advertisement
GNOOR1S

Botania Turtle

Aug 22nd, 2015
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.82 KB | None | 0 0
  1. --Youtube http://www.youtube.com/user/gnoor1s
  2. --Made by Gnoor1s/Gunnar
  3. --Most of this code is over engineered
  4. --But it's fun
  5.  
  6. --User changeable if needed
  7. local fuelSlot = 16
  8. local supplySlot = 15
  9. local homeBlockSlot = 2 --The slot for comparison for home location
  10. local checkHome = true
  11.  
  12. --Do not change (developers variables)
  13. local lastSlot = 0
  14. local t = turtle
  15. local running = true
  16. local version = "b2.9.1"
  17.  
  18. function init()
  19.     term.clear()
  20.     term.setCursorPos(1, 1)
  21.     print("Living Creator, version "..version)
  22.     print("Made by GNOOR1S on YouTube")
  23. end
  24.  
  25. function isBlockForward() -- Turtle breaking block if not forward
  26.     while not t.forward() do
  27.         t.dig()
  28.     end
  29.     fuel()
  30. end
  31.  
  32. function fuel()
  33.  
  34.   if t.getFuelLevel() <= 10 then
  35.     lastSlot = t.getSelectedSlot()
  36.     t.select(fuelSlot)
  37.     t.refuel(1)
  38.     t.select(lastSlot)
  39.   end
  40.  
  41.   if t.getFuelLevel() <= 1 then
  42.     print("Ran Out of fuel")
  43.     running = false
  44.   end
  45.  
  46. end
  47.  
  48. function collectBlocks()
  49.   print("Collecting Blocks")
  50.  
  51.   fuel()
  52.   t.dig()
  53.   isBlockForward()
  54.   t.dig()
  55.   isBlockForward()
  56.   t.dig()
  57.   isBlockForward()
  58.   t.turnLeft()
  59.  
  60.   for i = 1, 2 do
  61.     t.dig()
  62.     isBlockForward()
  63.   end
  64.  
  65.   fuel()
  66.   t.turnLeft()
  67.  
  68.   for i = 1, 2 do
  69.     t.dig()
  70.     isBlockForward()
  71.   end
  72.   t.turnLeft()
  73.   t.dig()
  74.   isBlockForward()
  75.   isBlockForward()
  76.   t.turnLeft()
  77.   fuel()
  78.   t.back()
  79. end
  80.  
  81. --Placing Blocks
  82. function placeBlocks()
  83.   print("Placing Blocks")
  84.  
  85.   t.select(supplySlot)
  86.  
  87.   fuel()
  88.   t.up()
  89.   isBlockForward()
  90.  
  91.   for i = 1, 2 do
  92.     t.placeDown()
  93.     isBlockForward()
  94.   end
  95.  
  96.   t.placeDown()
  97.  
  98.   fuel()
  99.   t.turnLeft()
  100.  
  101.   for i = 1, 2 do
  102.     t.placeDown()
  103.     isBlockForward()
  104.   end
  105.  
  106.   fuel()
  107.   t.placeDown()
  108.   t.turnLeft()
  109.  
  110.   for i = 1, 2 do
  111.     t.placeDown()
  112.     isBlockForward()
  113.   end
  114.  
  115.   t.turnLeft()
  116.   t.placeDown()
  117.   isBlockForward()
  118.   t.placeDown()
  119.   isBlockForward()
  120.   t.turnLeft()
  121.   t.back()
  122.   t.down()
  123. end
  124.  
  125. --Start of code
  126. init()
  127. while running do
  128.   sleep(5)
  129.  
  130.   if t.getItemCount(supplySlot) <= 7 then
  131.     print("Put resources in slot '15'")
  132.     break
  133.   end
  134.  
  135.   if t.getItemCount(1) >= 1 then
  136.     while true do
  137.     t.select(1)
  138.       if t.compare() == true then
  139.         if t.getItemCount(supplySlot) >= 8 then
  140.           print("Starting Methods")
  141.           print("")
  142.           sleep(5)
  143.           collectBlocks()
  144.           t.select(supplySlot)
  145.           placeBlocks()
  146.          
  147.          
  148.           if checkHome then
  149.            
  150.             lastSlot = t.getSelectedSlot()
  151.             t.select(homeBlockSlot)
  152.             if not t.compareDown() then
  153.                 running = false
  154.                 print("Turtle did not land in the right location")
  155.             end
  156.          
  157.           t.select(lastSlot)
  158.           end
  159.         else
  160.           print("Put resources in slot '15'")
  161.           running = false
  162.           break
  163.         end
  164.       else
  165.         sleep(5)
  166.       end
  167.     end
  168.   end
  169. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement