4ndertheker

[FTB] [Mining-Turtle] 2x3-Tunnel mit Rails & Fackeln

Apr 27th, 2013
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.23 KB | None | 0 0
  1. local torches=true --Fackeln an/aus (true/false)
  2. local rails=false --Schienen an/aus (true/false)
  3. local tl=100 --Tunnellaenge
  4. local fuelcheck=true --Turtles brauchen Fuel an/aus
  5.  
  6. local pos=0
  7. local sr=true
  8.  
  9. local function forward()
  10. while turtle.forward()==false do
  11.     turtle.dig()
  12.     turtle.attack()
  13.     turtle.suck()
  14.     sleep(.6)
  15. end
  16. end
  17.  
  18. local function up()
  19. while turtle.up()==false do
  20.     turtle.digUp()
  21.     turtle.attackUp()
  22.     turtle.suckUp()
  23.     sleep(.6)
  24. end
  25. end
  26.  
  27. local function down()
  28. while turtle.down()==false do
  29.     turtle.digDown()
  30.     turtle.attackDown()
  31.     turtle.suckDown()
  32.     sleep(.6)
  33. end
  34. end
  35.  
  36. local function zurueck()
  37.     if sr==false then
  38.         turtle.turnLeft()
  39.         forward()
  40.         turtle.turnLeft()
  41.         down()
  42.     else
  43.         turtle.turnLeft()
  44.         turtle.turnLeft()
  45.         down()
  46.     end
  47.     for i=pos, 1, -1 do
  48.         forward()
  49.     end
  50. end
  51.  
  52. local function kceuruz()
  53.         turtle.turnRight()
  54.         turtle.turnRight()
  55.         for i=1, pos, 1 do
  56.             forward()
  57.         end
  58.         if sr==false then
  59.             up()
  60.             turtle.turnRight()
  61.             forward()
  62.             turtle.turnLeft()
  63.         else
  64.             up()
  65.         end
  66. end
  67.  
  68. local function check()
  69. if torches==true then
  70.     if turtle.getItemCount(1)<=1 then
  71.         if pos>0 then
  72.             zurueck()
  73.         end
  74.         print("Keine Fackeln mehr. Bitte Fackeln in Slot 1 geben und [Enter] druecken")
  75.         io.read()  
  76.             if pos>0 then
  77.                 kceuruz()
  78.             end
  79.     end
  80.     if rails==true then
  81.     if turtle.getItemCount(2)<=1 then
  82.         if pos>0 then
  83.             zurueck()
  84.         end
  85.         print("Keine Schienen mehr. Bitte Schienen in Slot 2 geben und [Enter] druecken")
  86.         io.read()  
  87.         if pos>0 then
  88.             kceuruz()
  89.         end
  90.     end
  91.     end
  92. end
  93. end
  94.  
  95. local function unload()
  96.     if turtle.getItemCount(16)>0 then
  97.         zurueck()
  98.         local sn=3
  99.         repeat
  100.             turtle.select(sn)
  101.             turtle.drop()
  102.             sn=sn+1
  103.         until sn==17
  104.         turtle.select(1)
  105.         kceuruz()
  106.     end
  107. end
  108.  
  109. local function fuel()
  110.     if turtle.getFuelLevel()<=pos+3 then
  111.         zurueck()
  112.         turtle.select(3)
  113.         print("Kein Treibstoff mehr. Bitte Treibstoff in Slot 3 geben und [Enter] druecken.")
  114.         io.read()
  115.         turtle.refuel()
  116.         turtle.select(1)
  117.         kceuruz()
  118.     end
  119. end
  120.  
  121.  
  122. local function schicht()
  123.     check()
  124.     unload()
  125.     if fuelcheck==true then
  126.     fuel()
  127.     end
  128.     if sr==true then
  129.         turtle.dig()
  130.         forward()
  131.         turtle.digUp()
  132.         turtle.digDown()
  133.         turtle.turnRight()
  134.         turtle.dig()
  135.         forward()
  136.         turtle.digUp()
  137.         turtle.digDown()
  138.         if rails==true then
  139.             turtle.select(2)
  140.             turtle.placeDown()
  141.         end
  142.         turtle.turnLeft()
  143.     elseif sr==false then
  144.         turtle.dig()
  145.         forward()  
  146.         turtle.digUp()
  147.         turtle.digDown()
  148.         if rails==true then
  149.             turtle.select(2)
  150.             turtle.placeDown()
  151.         end
  152.         turtle.turnLeft()
  153.         turtle.dig()
  154.         forward()
  155.         turtle.digUp()
  156.         turtle.digDown()
  157.         turtle.turnRight()
  158.     end
  159.     sr=not sr
  160.     pos=pos+1
  161. end
  162.  
  163. local function fackel()
  164.     if torches==true then
  165.         turtle.select(1)
  166.         turtle.turnRight()
  167.         turtle.place()
  168.         turtle.turnLeft()
  169.  
  170.     end
  171. end
  172.  
  173. local function start()
  174.         check()
  175.         turtle.digUp()
  176.         up()
  177.         if tl>=4 then
  178.             for i=1, 4, 1 do
  179.                 schicht()
  180.             end
  181.                 fackel()
  182.                 tl=tl-4
  183.         end
  184. end
  185.  
  186. -----------------------------------
  187.  
  188. start()
  189. for i=tl, 0, -1 do
  190.     if i>=8 then
  191.         for i=1, 8, 1 do
  192.             schicht()
  193.         end
  194.         fackel()
  195.     else
  196.         schicht()
  197.     end
  198. end
  199. zurueck()
  200. turtle.turnLeft()
  201. turtle.turnLeft()
  202. print("Bau des Tunnels scheint beendet.")
Advertisement
Add Comment
Please, Sign In to add comment