Thor_s_Crafter

draconium2

Jun 30th, 2016
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.69 KB | None | 0 0
  1. -- Automatische Awakened Draconium Farm --
  2. -- Draconic Evolution --
  3. -- von Thor_s_Crafter --
  4. -- Version 1.1 --
  5.  
  6. t = turtle
  7. local anzahl = 0
  8.  
  9. shell.run("label set draconiumTurtle")
  10.  
  11. function autoUpdate()
  12.   if not fs.exists("startup") then
  13.     local file = fs.open("startup","w")
  14.     file.writeLine("shell.run(\"rm draconium\")")
  15.     file.writeLine("shell.run(\"pastebin get u4B8E9DJ draconium\")")
  16.     file.writeLine("shell.run(\"draconium\")")
  17.     file.close()
  18.   end
  19. end
  20.  
  21. function start()
  22.   term.clear()
  23.   term.setCursorPos(1,1)
  24.   print("-- Draconium Turtle --")
  25.   print("Programmbeschreibung: ")
  26.   print("Diese Turtle stellt automatisch Awakened Draconium her.")
  27.   print("Nach Abschluss eines Durchlaufs muss jedoch das Awakened Draconium von Hand abgebaut werden.")
  28.   print("Alternativ koennen die Bloecke mithilfe von Applied Energistics Annihilation Planes abgebaut werden.")
  29.   getEnter()
  30.   local yn = yesNoInput("Soll eine detaillierte Erklaerung ueber das Programm angezeigt werden (j/n)?")
  31.   if  yn then
  32.     displayInfos()
  33.   end
  34. end
  35.  
  36. function displayInfos()
  37.   term.clear()
  38.   term.setCursorPos(1,1)
  39.   print("-- Aufbau der Draconium Farm --")
  40.   print("Benoetigte Materialien:")
  41.   print("- 1 Mining- oder Advanced Mining Turtle")
  42.   print("- 4 Kisten")
  43.   print("- Obsidian")
  44.   print("Optionale Materialien: ")
  45.   print("- 1 Computer mit einem Wireless Modem")
  46.   print("- 8 Monitore (4 breit,2 hoch)")
  47.   print("- 1 Wireless Modem fuer die Turtle")
  48.   getEnter()
  49.   term.clear()
  50.   term.setCursorPos(1,1)
  51.   print("-- Aufbau der Draconium Farm --")
  52.   print("Aufbau:")
  53.   print("Ein Obsidianraum. Mindestmaß: 4x4x4 Bloecke (Außenmaß).")
  54.   print("Die Turtle muss aussen vor eine Wand platziert werden. Hoehe: 2 Bloecke über dem Obsidian Boden")
  55.   print("Die 4 Kisten muessen rechts,hinten,links und oberhalb der Turtle sein.")
  56.   getEnter()
  57.   term.clear()
  58.   term.setCursorPos(1,1)
  59.   print("-- Aufbau der Draconium Farm --")
  60.   print("Inhalt der Kisten:")
  61.   print("- links: Charged Draconium Bloecke (4 Stk.)")
  62.   print("- unten: Drachenherzen (1 Stk.)")
  63.   print("- rechts: Draconic Cores (16 Stk.)")
  64.   print("- oben: TNT (1 Stk.)")
  65.   getEnter()
  66.   term.clear()
  67.   term.setCursorPos(1,1)
  68.   print("Weitere Information + Bilder + Videos zum Aufbau findet ihr auf meinem YouTube-Kanal.:")
  69.   print("https://www.youtube.com/channel/UCEG-Oq2LlJwkrqYu_AvfK0Q")
  70.   print("oder Suche nach Thor_s_Crafter")
  71.   getEnter()
  72. end
  73.  
  74. function userInput()
  75.   if t.getFuelLevel() < 100 then
  76.     fuelInput()
  77.   end
  78.   term.clear()
  79.   term.setCursorPos(1,1)
  80.   print("Wie viele Runden sollen durchlaufen werden?")
  81.   write("Eingabe: ")
  82.   local input = read()
  83.   anzahl = tonumber(input)
  84. end
  85.  
  86. function fuelInput()
  87.   term.clear()
  88.   term.setCursorPos(1,1)
  89.   t.select(16)
  90.   print("Bitte Fuel nachfuellen!")
  91.   print("Fuel bitte in Slot 16 legen")
  92.   while not (t.getFuelLevel() > 100) do
  93.     t.refuel()
  94.   end
  95. end
  96.  
  97. function getEnter()
  98.   write("Enter druecken...")
  99.   local event,key = os.pullEvent("key")
  100.   while key ~= 28 do
  101.     sleep(0.5)
  102.     event,key = os.pullEvent("key")
  103.   end
  104. end
  105.  
  106. function yesNoInput(msg)
  107.   local input
  108.   while not (input == "j" or input == "n") do
  109.     term.clear()
  110.     term.setCursorPos(1,1)
  111.     print(msg)
  112.     write("Eingabe: ")
  113.     input = read()
  114.   end
  115.   if input == "j" then
  116.     return true
  117.   elseif input == "n" then
  118.     return false
  119.   end
  120. end
  121.  
  122. ---
  123.  
  124. function takeItems()
  125.    t.turnLeft()
  126.   -- Charged Draconium Blöcke
  127.   t.select(5)
  128.   local success = t.suck(4)
  129. --  if not (success and t.getItemCount() == 4) then
  130. --    t.drop()
  131. --    t.turnRight()
  132. --    error("Nicht genug Charged Draconium Blöcke.")
  133. --  end
  134.   t.turnLeft()
  135.   -- Drachenherz
  136.   t.select(6)
  137.   local success2 = t.suckDown(1)
  138. --  if not success2 then
  139. --    t.turnRight()
  140. --    t.select(5)
  141. --    t.drop()
  142. --    t.turnRight()
  143. --    error("Nicht genug Drachenherzen.")
  144. --  end
  145.   t.turnLeft()
  146.   -- Draconic Cores
  147.   t.select(7)
  148.   local success3 = t.suck(16)
  149. --  if not (success3 and t.getItemCount() == 16) then
  150. --    t.drop()
  151. --    t.turnRight()
  152. --    t.select(6)
  153. --    t.drop()
  154. --    t.turnRight()
  155. --    t.select(5)
  156. --    t.drop()
  157. --    t.turnRight()
  158. --    error("Nicht genug Draconic Cores.")
  159. --  end
  160.   t.turnLeft()
  161.   -- TNT
  162.   t.select(8)
  163.   local success4 = t.suckUp(1)
  164. --  if not success4 then
  165. --    t.turnRight()
  166. --    t.select(7)
  167. --    t.drop()
  168. --    t.turnRight()
  169. --    t.select(6)
  170. --    t.drop()
  171. --    t.turnRight()
  172. --    t.select(5)
  173. --    t.drop()
  174. --    t.turnRight()
  175. --    error("Nicht genug TNT")
  176. --  end
  177.   anzahl = 1
  178. end
  179.  
  180.  
  181. function placeAll()
  182.   for i=1,anzahl,1 do
  183.     term.clear()
  184.     term.setCursorPos(1,1)
  185.     print("Durchlauf "..i.."/"..anzahl)
  186.     print("Bitte Magnten o.a. ausschalten!")
  187.     print()
  188.  
  189.     t.select(1)
  190.     -- Obsidian abbauen
  191.     t.dig()
  192.     t.forward()
  193.     t.forward()
  194.     t.forward()
  195.  
  196.     print("Setze Bloecke/TNT/Drachenherz...")
  197.     -- Draconium setzen
  198.     t.select(5)
  199.     t.placeDown()
  200.     t.forward()
  201.     t.placeDown()
  202.     t.turnRight()
  203.     t.forward()
  204.     t.placeDown()
  205.     t.turnRight()
  206.     t.forward()
  207.     t.placeDown()
  208.     t.turnRight()
  209.  
  210.     -- TNT setzen
  211.     t.select(8)
  212.     t.place()
  213.     -- Drachenherz hinwerfen
  214.     t.turnRight()
  215.     t.back()
  216.     t.select(6)
  217.     t.drop(1)
  218.     t.turnLeft()
  219.     t.forward()
  220.     -- TNT anzünden
  221.     t.turnRight()
  222.     rs.setOutput("front",true)
  223.     sleep(2)
  224.     rs.setOutput("front",false)
  225.     t.back()
  226.     t.back()
  227.     t.select(1)
  228.     t.place()
  229.    
  230.     -- Warte bis TNT gezündet ist
  231.     print("Warte 10 Sekunden...")
  232.     sleep(10)
  233.  
  234.     -- Draconic Cores hinwerfen
  235.     print("Setze Draconic Cores...")
  236.     t.dig()
  237.     t.forward()
  238.     t.select(7)
  239.     -- Zurück
  240.     t.drop(16)
  241.     t.back()
  242.     t.select(1)
  243.     t.place()
  244.  
  245.     print("Warte auf naechsten Durchlauf... (30 Sec.)")
  246.     sleep(30)
  247.     if i < anzahl then
  248.       takeItems()
  249.     end
  250.   end
  251.   term.clear()
  252.   term.setCursorPos(1,1)
  253. end
  254.  
  255. function checkContent()
  256.     term.setCursorPos(1,1)
  257.  
  258.     local c1 = peripheral.wrap("left")
  259.     local c2 = peripheral.wrap("bottom")
  260.     local c3 = peripheral.wrap("right")
  261.     local c4 = peripheral.wrap("top")
  262.  
  263.     c1.condenseItems()
  264.     c2.condenseItems()
  265.     c3.condenseItems()
  266.     c4.condenseItems()
  267.  
  268.     if c1.getAllStacks()[1] == nil then print("Kein Draconium!      ") return false end
  269.     if c2.getAllStacks()[1] == nil then print("Keine Drachenherzen!      ") return false end
  270.     if c3.getAllStacks()[1] == nil then print("Keine Draconic Cores!      ")return false end
  271.     if c4.getAllStacks()[1] == nil then print("Kein TNT!      ") return false end
  272.  
  273.     local c1con = c1.getAllStacks()[1].all()
  274.     local c2con = c2.getAllStacks()[1].all()
  275.     local c3con = c3.getAllStacks()[1].all()
  276.     local c4con = c4.getAllStacks()[1].all()
  277.  
  278.     local check1 = false
  279.     local check2 = false
  280.     local check3 = false
  281.     local check4 = false
  282.  
  283.     if c1con.name == "draconium" and c1con.dmg == 2 and c1con.dmg == 2 and c1con.qty >= 4 then
  284.         check1 = true
  285.         print("Draconium OK.        ")
  286.     else print("Zu wenig Draconium!      ") end
  287.     if c2con.name == "dragonHeart" then
  288.         check2 = true
  289.         print("Drachenherzen OK.      ")
  290.     else print("Zu wenig Drachenherzen!      ") end
  291.     if c3con.name == "draconicCore" and c3con.qty >= 16 then
  292.         check3 = true
  293.         print("Draconic Cores OK.      ")
  294.     else print("Zu wenig Draconic Cores!      ") end
  295.     if c4con.name == "tnt" then
  296.         check4 = true
  297.         print("TNT OK.      ")
  298.     else print("Zu wenig TNT!      ") end
  299.  
  300.     if check1 and check2 and check3 and check4 then
  301.         return true
  302.     end
  303.  
  304.     return false
  305. end
  306.  
  307. term.clear()
  308. term.setCursorPos(1,1)
  309.  
  310. if t.getFuelLevel() < 100 then fuelInput() end
  311. while true do
  312.     term.setCursorPos(1,1)
  313.     if checkContent() then
  314.         takeItems()
  315.         placeAll()
  316.     end
  317.     sleep(0.5)
  318. end
Advertisement
Add Comment
Please, Sign In to add comment