cracylord

Standardtunnel mit Return

Sep 22nd, 2014
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.76 KB | None | 0 0
  1. -- Kompatibel mit TurtleOS 1.5
  2. -- Standardtunnel 1x2
  3.  
  4. TunnelLaenge=50
  5. QuerTunnelLaenge=2
  6. FackelEntfernung=8
  7. TunnelZurueckgelegt=0
  8.  
  9. --############################
  10.  
  11. function turnAround()
  12.     turtle.turnRight()
  13.     turtle.turnRight()
  14. end
  15.  
  16. function placeTorch()
  17.     if TunnelZurueckgelegt%FackelEntfernung==2 then
  18.         turnAround()
  19.         if turtle.getItemCount(16)>0 then
  20.             turtle.select(16)
  21.             turtle.place(X)
  22.         end
  23.         turnAround()
  24.     end
  25. end
  26.  
  27. function refuel()
  28.     turtle.select(15)
  29.     if turtle.getItemCount(15)  == 0 then
  30.         print ("Kein Treibstoff! (Slot 15)")
  31.     end
  32.  
  33.     if turtle.getFuelLevel()<=50 then
  34.     turtle.refuel(1)
  35.     end
  36. end
  37.  
  38. function up()
  39.     if turtle.detectUp() then
  40.     print ("UP")
  41.         turtle.digUp()
  42.     end
  43. end
  44.  
  45. function down()
  46.     if turtle.detect() then
  47.         print ("FRONT")
  48.         turtle.dig()
  49.     end
  50. end
  51.  
  52. function tunnel(tunnelentf)
  53.     while tunnelentf>TunnelZurueckgelegt do
  54.         print ("StartSchleife")
  55.         -- nachfuellen
  56.         refuel()
  57.         -- oben abbauen
  58.         up()
  59.         --vorne abbauen
  60.         down()
  61.         --1 vorgehen
  62.         turtle.forward()
  63.         TunnelZurueckgelegt= TunnelZurueckgelegt + 1 --boah was 'ne kacksprache die kein ++ increment zulaesst
  64.  
  65.         -- Fackeln platzieren
  66.         placeTorch()
  67.     end
  68.     up()
  69. end
  70.  
  71. function querTunnel(tunnelentf)
  72.     turtle.turnRight()
  73.     tunnel(tunnelentf)
  74.     turtle.turnRight()
  75. end
  76.  
  77. function go(entf)
  78.     x=0
  79.     while entf>=x do
  80.         turtle.forward()
  81.         x=x+1
  82.     end
  83. end
  84. --############################
  85.  
  86. print ("Anfang")
  87. tunnel(TunnelLaenge)
  88. querTunnel(5)
  89. turtle.turnRight()
  90. go 2
  91. turtle.turnLeft()
  92. tunnel(TunnelLaenge)
  93. print ("Programmende")
Add Comment
Please, Sign In to add comment