psychedelixx

Minecraft Turtle: Chest Tunnel (Robust)

Mar 25th, 2014 (edited)
353
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --[[
  2.     2014 (c) psychedelixx
  3.     Minecraft Turtle: Chest Tunnel (Robust)
  4.     2014-03-25
  5.  
  6.     Digs a tunnel and places mined items in chests.
  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 cMBykysF ct"
  15.         - type "ct <length> [<return (0|1)>]"
  16.         - place chests in slot 15
  17.         - place torches in slot 16
  18. --]]
  19. os.loadAPI("t")
  20. i = 0
  21. ret = 1
  22.  
  23. function move()
  24.     i = i+1
  25.    
  26.     print("----------------")
  27.     print("Remaining fuel: " .. turtle.getFuelLevel())
  28.     print("Digged: " .. i .. "/" .. length .. "(" .. math.floor(100/length*i) .. "%)")
  29.     print("Next torch in " .. 9-i%8)
  30.     print("Next chest in " .. 33-i%32)
  31.     print("")
  32.    
  33.     --[[ Vorwärts graben und bewegen ]]--
  34.     t.dig()
  35.     t.forward()
  36.    
  37.     --[[ Hoch bzw. runter graben ]]--
  38.     if i%2 == 1 then
  39.         t.digUp()
  40.     else
  41.         t.digDown()
  42.     end
  43.    
  44.     --[[ Links graben ]]--
  45.     t.left()
  46.     t.dig()
  47.    
  48.     --[[ Chest setzen und Items ablegen ]]--
  49.     if i%32 == 1 and i > 5 then
  50.         turtle.select(15)
  51.         turtle.place()
  52.         for slot = 1, 14 do
  53.             turtle.select(slot)
  54.             turtle.drop()
  55.         end
  56.     end
  57.    
  58.     --[[ Rechts graben ]]--
  59.     t.turnAround()
  60.     t.dig()
  61.    
  62.     --[[ Fackel setzen ]]--
  63.     if i%8 == 1 then
  64.         turtle.select(16)
  65.         turtle.place()
  66.     end
  67.  
  68.     --[[ Hoch bzw. runter bewegen ]]-- 
  69.     if i%2 == 1 then
  70.         t.up()
  71.         t.digUp()
  72.     else   
  73.         t.digUp()
  74.         t.down()
  75.     end
  76.    
  77.     --[[ Rechts graben ]]--
  78.     t.dig()
  79.    
  80.     --[[ Links graben ]]--
  81.     t.turnAround()
  82.     t.dig()
  83.    
  84.     --[[ Nach vorne drehen ]]--
  85.     t.right()  
  86.    
  87.     --[[ Sand/Kies entfernen ]]--
  88.     t.digUp()
  89. end
  90.  
  91. local args = { ... }
  92. if #args < 1 then
  93.     print("")
  94.     print("ct <length> [<return (0|1)>]")
  95.     print("place chests in slot 15")
  96.     print("place torches in slot 16")
  97.     print("")
  98.  
  99.     error()
  100. end
  101.  
  102. length = tonumber(args[1])
  103.  
  104. if #args == 2 then
  105.     ret = tonumber(args[2])
  106. end
  107.  
  108. if turtle.getFuelLevel() < length*2 + length*ret then
  109.     print("I need fuel!")
  110.     print((length*2 + length*ret) - turtle.getFuelLevel() .. " fuel missing")
  111.     print("Refuel with " .. ((length*2 + length*ret) - turtle.getFuelLevel())/80+1 .. " pieces of coal")
  112. else
  113.     print("======== 2014 (c) psychedelixx ========")
  114.     print("Let's go!")
  115.     print("Digging " .. length)
  116.    
  117.     for l = 1, length do
  118.         move()
  119.     end
  120.    
  121.     if ret == 1 then
  122.         t.turnAround()
  123.         t.forward(length)
  124.     end
  125. end
Add Comment
Please, Sign In to add comment