DerMarten

[Computercraft][2022][NEW]Stripmine

Jan 1st, 2022 (edited)
444
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.93 KB | None | 0 0
  1. -- Erstellt von DerMarten Web: http://pastebin.com/u/DerMarten
  2. -- Tutrtle Api: http://computercraft.info/wiki/Turtle_(API)
  3. function toBool(data)
  4.     if data == "true" or data == "TRUE" then
  5.         return true
  6.     else
  7.         return false
  8.     end
  9. end
  10. local args = { ... }
  11. local laenge = 0
  12. local breite = 6
  13. local torch = false
  14. local timesleep = 0.4
  15. local torchSlot = 16
  16. local status = 0
  17. if tonumber(args[1]) >= 1 then
  18.     if tonumber(args[1]) >= 1 then
  19.         laenge = tonumber(args[1])
  20.     end
  21.     if args[2] == nil then
  22.         breite = 6
  23.     else
  24.         breite = tonumber(args[2])
  25.     end
  26.     if args[3] == nil then
  27.         torch = true
  28.     else
  29.         torch = toBool(args[3])
  30.     end
  31. end
  32.     --print("Länge: "..laenge.." - Typ: "..type(laenge))
  33.     --print("Breite: "..breite.." - Typ: "..type(breite))
  34.     --print("Fakeln: "..tostring(torch).." - Typ: "..type(torch))
  35.  
  36. -- Funktionen --
  37. function dig()
  38.     if turtle.detect() then
  39.         turtle.dig()
  40.         os.sleep(timesleep)
  41.     end
  42. end
  43. function digUp()
  44.     if turtle.detectUp() then
  45.         turtle.digUp()
  46.         os.sleep(timesleep)
  47.     end
  48. end
  49. function digDown()
  50.     if turtle.detectDown() then
  51.         turtle.digDown()
  52.         os.sleep(timesleep)
  53.     end
  54. end
  55. function torchCheck()
  56.     local data = turtle.getItemDetail()
  57.  
  58.     if data then
  59.         if data.name == "minecraft:torch" then
  60.             return true
  61.         else
  62.             return false
  63.         end
  64.     end
  65. end
  66.  
  67. function placeTorch()
  68.     if torch then
  69.         turtle.select(torchSlot)
  70.         if torchCheck() then
  71.             turtle.turnLeft()
  72.             turtle.placeUp()
  73.             turtle.turnRight()
  74.         end
  75.         turtle.select(1)
  76.     end
  77. end
  78.  
  79. -- Movement Functions
  80. function forward()
  81.     while turtle.detect() do
  82.         dig()
  83.     end
  84.     turtle.forward()
  85. end
  86. function up()
  87.     while turtle.detectUp() do
  88.         digUp()
  89.     end
  90.     turtle.up()
  91. end
  92. function down()
  93.     while turtle.detectDown() do
  94.         digDown()
  95.     end
  96.     turtle.down()
  97. end
  98.  
  99.  
  100. -- Mainloop
  101. if args[1] == "help" then
  102. print("Syntax: Stripmine <Einheiten [NUMBER]> <Nebengang Breite [NUMBER]> <Fakeln [BOOL]>")
  103. print("1 Einheit = 3 Blöcke Lang")
  104. else
  105.     if laenge > 0 then
  106.         if breite > 0 then
  107.            
  108.             local templ = 0
  109.             for i = laenge,1,-1 do
  110.                 status = status + 1
  111.                 shell.run("clear")
  112.                 print("Aktuelle Einheit: "..status)
  113.                 templ = templ + 1
  114.                 -- Hauptgang
  115.                 for i = 3,1,-1 do
  116.                     forward()
  117.                     digUp()
  118.                     if i == 2 then
  119.                         placeTorch()
  120.                     end
  121.                 end
  122.                 turtle.turnRight()
  123.                
  124.                 -- Rechts
  125.                 for i = breite,1,-1 do
  126.                     forward()
  127.                     digUp()
  128.                 end
  129.                 turtle.turnRight()
  130.                 turtle.turnRight()
  131.                 for i = breite,1,-1 do
  132.                 forward()
  133.                 digUp()
  134.                 end
  135.                
  136.                 -- Links
  137.                 for i = breite,1,-1 do
  138.                     forward()
  139.                     digUp()
  140.                 end
  141.                 turtle.turnLeft()
  142.                 turtle.turnLeft()
  143.                 for i = breite,1,-1 do
  144.                     forward()
  145.                     digUp()
  146.                 end
  147.                 if templ ~= laenge then
  148.                     turtle.turnLeft()
  149.                 end
  150.                
  151.                
  152.             end
  153.             --turtle.turnRight()
  154.             turtle.turnRight()
  155.             for i = laenge*3,1,-1 do
  156.                 forward()
  157.             end
  158.             turtle.turnLeft()
  159.             turtle.turnLeft()
  160.             up()
  161.             up()
  162.            
  163.         end
  164.     end
  165. end
Advertisement
Add Comment
Please, Sign In to add comment