Thor_s_Crafter

draconicTurtleEN

Apr 4th, 2016
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.96 KB | None | 0 0
  1. -- Automatic Dragonfarm - Draconic Evolution --
  2. -- Turtleprogram by Thor_s_Crafter --
  3. -- Version 1.1--
  4.  
  5. t = turtle
  6.  
  7. local fuel = 0
  8. local amount = 0
  9.  
  10. -- Checks, how the current fuelLevel is
  11. function checkFuel()
  12.     while t.getFuelLevel() < 100 do
  13.         fuelInput()
  14.     end
  15. end
  16.  
  17. -- Asks the User to refuel the turtle
  18. function fuelInput()
  19.     term.clear()
  20.     term.setCursorPos(1,1)
  21.     t.select(16)
  22.     print("Please refuel the turtle!")
  23.     print("Drop the fuel in slot 16!")
  24.     write("Press Enter...")
  25.     local leer = read()
  26.     t.refuel()
  27.     fuel = t.getFuelLevel()
  28. end
  29.  
  30. -- Takes items out of the chests
  31. function takeItems()
  32.     t.turnLeft()
  33.     t.select(5)
  34.     t.suck(1)
  35.     t.turnLeft()
  36.     t.select(6)
  37.     t.suck(1)
  38.     t.turnLeft()
  39.     t.turnLeft()
  40. end
  41.  
  42. -- Takes the Cobblestone (or other building material)
  43. function takeCobble()
  44.     t.turnRight()
  45.     t.select(7)
  46.     t.suck()
  47.     t.turnLeft()
  48. end
  49.  
  50. -- Drops all items into the top chest
  51. function dropItems()
  52.     for i=1,16,1 do
  53.         t.select(i)
  54.         t.dropUp()
  55.     end
  56.     t.select(1)
  57. end
  58.  
  59. -- Moving
  60. function placeApiary()
  61.     for i=0,7,1 do
  62.         t.forward()
  63.     end
  64.     -- Taking the dragon egg
  65.     t.select(1)
  66.     t.dig()
  67.     -- Placing the apiary
  68.     t.select(5)
  69.     t.place()
  70.     -- Puts the bees into the apiary
  71.     t.select(6)
  72.     t.drop()
  73.     -- Move back
  74.     for i=0,7,1 do
  75.         t.back()
  76.     end
  77. end
  78.  
  79. -- Placing the Cobblestone (or other building material)
  80. function placeCobble()
  81.     for i=0,7,1 do
  82.         t.forward()
  83.     end
  84.     t.select(9)
  85.     t.dig()
  86.     t.down()
  87.     -- Remove the torch
  88.     t.select(2)
  89.     t.digDown()
  90.     t.down()
  91.     t.back()
  92.     t.turnRight()
  93.  
  94.     -- Placing Cobblestone
  95.     t.select(7)
  96.     t.placeDown()
  97.     t.forward()
  98.     t.placeDown()
  99.     t.forward()
  100.     t.turnLeft()
  101.  
  102.     for i=0,2,1 do
  103.         for i=0,3,1 do
  104.             t.placeDown()
  105.             t.forward()
  106.         end
  107.         t.placeDown()
  108.         t.turnLeft()
  109.     end
  110.  
  111.     t.forward()
  112.     t.placeDown()
  113.  
  114.     t.turnLeft()
  115.     t.forward()
  116.     t.turnRight()
  117.  
  118.     for i=0,3,1 do
  119.         for i=0,1,1 do
  120.             t.placeDown()
  121.             t.dig()
  122.             t.forward()
  123.         end
  124.         t.turnLeft()
  125.     end
  126.  
  127.     t.forward()
  128.     t.turnLeft()
  129.     t.up()
  130.     t.up()
  131.  
  132.     -- Moving back
  133.     for i=0,7,1 do
  134.         t.back()
  135.     end
  136. end
  137.  
  138. -- Starts at the beginning
  139. function userInput()
  140.     term.clear()
  141.     term.setCursorPos(1,1)
  142.     print("This program automatically spawns and kills Enderdragons.")
  143.     print("The following setup is necessary: ")
  144.     print("You need a Mining Turtle or an Advanced Mining Turtle.")
  145.     print("4 Chest must be in place:")
  146.     print("The left chest needs to contain an apiary.")
  147.     print("The back chest needs to contain Phantasmal-Bees (Queens).")
  148.     print("Press Enter...")
  149.     local leer = read()
  150.     term.clear()
  151.     term.setCursorPos(1,1)
  152.     print("The right chest needs to contain any building material.")
  153.     print("The top chest should be empty.")
  154.     print("The turtle drops all items into the top chest after every cycle.")
  155.     print("The items should be routed from there.")
  156.     print("Press Enter...")
  157.     leer = read()
  158.     term.clear()
  159.     term.setCursorPos(1,1)
  160.     print("How many cycles do you want to run?")
  161.     write("Input: ")
  162.     local input = read()
  163.     amount = tonumber(input)
  164. end
  165.  
  166. -- Installing a  Startup
  167. function install()
  168.     print("-- Dragonfarm program --")
  169.     print("-- by Thor_s_Crafter --")
  170.     print("-- Version 1.1 --")
  171.     print()
  172.     local input
  173.     if not fs.exists("startup") then
  174.         while not (input == "y" or input == "n") do
  175.             term.clear()
  176.             term.setCursorPos(1,1)
  177.             print("Should the program start automatically (adding a startup) (y/n) ?")
  178.             write("Input: ")           
  179.             input = read()
  180.             if input == "y" then
  181.                 local file = fs.open("startup","w")
  182.                 file.writeLine("shell.run(\"rm dragon\")")
  183.                 file.writeLine("shell.run(\"pastebin get dBMCtQQR dragon\")")
  184.                 file.writeLine("shell.run(\"dragon\")")
  185.                 file.close()
  186.             end
  187.         end
  188.     end
  189.    
  190. end
  191.  
  192. install()
  193. userInput()
  194. for i=1,amount,1 do
  195.     checkFuel()
  196.     takeItems()
  197.     placeApiary()
  198.     dropItems()
  199.     rs.setOutput("bottom",true)
  200.     sleep(40)
  201.     rs.setOutput("bottom",false)
  202.     takeCobble()
  203.     placeCobble()
  204. end
  205.  
  206. term.clear()
  207. term.setCursorPos(1,1)
  208. print("-- Done --")
  209. print("-- Program terminated --")
Advertisement
Add Comment
Please, Sign In to add comment