Advertisement
psychedelixx

Minecraft Turtle: Tesseract Tunnel (Robust)

Apr 13th, 2014
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --[[
  2.     2014 (c) psychedelixx
  3.     Minecraft Turtle: Tesseract Tunnel (Robust)
  4.     2014-04-13
  5.  
  6.     Digs a tunnel and places mined items in a tesseract.
  7.  
  8.     Robust API:
  9.     http://computercraft.info/wiki/Robust_Turtle_API
  10.  
  11.     Usage:
  12.         - use turtle and type "label set <name>"
  13.           (to give your turtle an unique name so it remembers its programs)
  14.         - type "pastebin get TnEEWzLJ tt"
  15.         - type "tt <length> [<return (0|1)>]"
  16.         - place torches in slot 16
  17. --]]
  18.  
  19. i = 0
  20. ret = 1
  21.  
  22. function move()
  23.     i = i+1
  24.    
  25.     print("----------------")
  26.     print("Remaining fuel: " .. turtle.getFuelLevel())
  27.     print("Digged: " .. i .. "/" .. length .. "(" .. math.floor(100/length*i) .. "%)")
  28.     print("Next torch in " .. 9-i%8)
  29.     print("")
  30.    
  31.     --[[ Vorwärts graben und bewegen ]]--
  32.     t.dig()
  33.     t.forward()
  34.    
  35.     --[[ Hoch bzw. runter graben ]]--
  36.     if i%2 == 1 then
  37.         t.digUp()
  38.     else
  39.         t.digDown()
  40.     end
  41.    
  42.     --[[ Links graben ]]--
  43.     t.left()
  44.     t.dig()
  45.    
  46.     --[[ Rechts graben ]]--
  47.     t.turnAround()
  48.     t.dig()
  49.    
  50.     --[[ Fackel setzen ]]--
  51.     if i%8 == 1 then
  52.         turtle.select(16)
  53.         turtle.place()
  54.     end
  55.  
  56.     --[[ Hoch bzw. runter bewegen ]]-- 
  57.     if i%2 == 1 then
  58.         t.up()
  59.         t.digUp()
  60.     else   
  61.         t.digUp()
  62.         t.down()
  63.     end
  64.    
  65.     --[[ Rechts graben ]]--
  66.     t.dig()
  67.    
  68.     --[[ Links graben ]]--
  69.     t.turnAround()
  70.     t.dig()
  71.    
  72.     --[[ Nach vorne drehen ]]--
  73.     t.right()  
  74.    
  75.     --[[ Sand/Kies entfernen ]]--
  76.     t.digUp()
  77. end
  78.  
  79. local args = { ... }
  80. if #args < 1 then
  81.     print("")
  82.     print("tt <length> [<return (0|1)>]")
  83.     print("place torches in slot 16")
  84.     print("")
  85.  
  86.     error()
  87. end
  88.  
  89. length = tonumber(args[1])
  90.  
  91. if #args == 2 then
  92.     ret = tonumber(args[2])
  93. end
  94.  
  95. if turtle.getFuelLevel() < length*2 + length*ret then
  96.     print("I need fuel!")
  97.     print((length*2 + length*ret) - turtle.getFuelLevel() .. " fuel missing")
  98.     print("Refuel with " .. ((length*2 + length*ret) - turtle.getFuelLevel())/80+1 .. " pieces of coal")
  99. else
  100.     print("======== 2014 (c) psychedelixx ========")
  101.     print("Let's go!")
  102.     print("Digging " .. length)
  103.    
  104.     for l = 1, length do
  105.         move()
  106.  
  107.         if i%2 == 0 then
  108.             empty = 0
  109.             for slot = 1, 15 do
  110.                 if turtle.getItemCount(slot) == 0 then
  111.                     empty = empty + 1
  112.                     if empty >= 2 then break end
  113.                 end
  114.             end
  115.             if empty <= 1 then
  116.                 t.turnAround()
  117.                 t.forward(l)
  118.                 for slot = 1, 15 do
  119.                     turtle.select(slot)
  120.                     turtle.drop()
  121.                 end
  122.                 t.turnAround()
  123.                 t.forward(l)
  124.             end
  125.         end
  126.     end
  127.    
  128.     if ret == 1 then
  129.         t.turnAround()
  130.         t.forward(length)
  131.         if i%2 == 1 then t.down() end
  132.        
  133.         for slot = 1, 16 do
  134.             turtle.select(slot)
  135.             turtle.drop()
  136.         end
  137.     end
  138. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement