Advertisement
sasaa86

Untitled

Aug 25th, 2017
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- computercraft mine stairs program
  2. -- options for Enderchest, torches, normal chests and loot-only
  3. -- ########## NOT READY #############
  4.  
  5. local useEnderChest = false                                 -- place a enderchest, dump stuff in it and collect chest?
  6. local enderChestSlot = 2                                -- slot to place enderchest
  7. local useNormalChest = false                                -- place a chest, dump stuff in it and move on?
  8. local normalChestSlot = 3                               -- slot to place chests
  9. local lootOnly = true                                   -- discard dirt cobble etc?
  10. local useTorch = false                                  -- place torches along path?
  11. local torchSlot = 1                                 -- turtle slot to put torches
  12. local torchInterval = 8                                 -- place torch every X blocks
  13. local tdepth = 30                                   -- tunnels for 30 blocks
  14.  
  15. torchNeeded = math.floor(tdepth / torchInterval)                    -- calculating needed torches
  16.  
  17.  
  18. shell.run("clear")
  19. local temp1 = turtle.getItemDetail(enderChestSlot)
  20. local temp2 = turtle.getItemDetail(normalChestSlot)
  21.  
  22. if temp1.name != "ender_chest" then
  23.     print("no Enderchest found in slot ".. enderChestSlot)
  24.     exit()
  25. end
  26.  
  27. if temp2.name != "chest" then
  28.     print("no chest found in slot ".. normalChestSlot)
  29.     exit()
  30. else
  31.     print("Found " .. temp2.count .. "chests in slot " .. normalChestSlot)
  32. end
  33.  
  34. if turtle.detectDown() then
  35.     turtle.up()
  36. end
  37. for i=0,tdepth do
  38.     turtle.digDown()
  39.     turtle.down()
  40.     while turtle.dig() do
  41.         -- waiting for gravel or sand to fall down
  42.         sleep(.2)
  43.     end
  44.     turtle.forward()
  45.     turtle.digDown()
  46.     if turtle.getItemCount(16) != 0 then
  47.         if useEnderChest then
  48.             turtle.select(enderChestSlot)
  49.             turtle.placeUp()
  50.             if lootOnly then
  51.                 for slot=4, 16 do
  52.                     info = turtle.getItemDetail(slot)
  53.                     if info.name != "cobblestone" or info.name != "dirt" or info.name != "gravel" or info.name != "sand" then
  54.                         turtle.select(slot)
  55.                         turtle.dropUp()
  56.                     else
  57.                         turtle.select(slot)
  58.                         turtle.dropDown()
  59.                     end
  60.                 end
  61.             else
  62.                 for slot=4, 16 do
  63.                     turtle.select(slot)
  64.                     turtle.dropUp()
  65.                 end
  66.             end
  67.         else if useNormalChest then
  68.             turtle.select(normalChestSlot)
  69.             if lootOnly then
  70.                 for slot=4, 16 do
  71.                     info = turtle.getItemDetail(slot)
  72.                     if info.name != "cobblestone" or info.name != "dirt" or info.name != "gravel" or info.name != "sand" then
  73.                         turtle.select(slot)
  74.                         turtle.dropUp()
  75.                     else
  76.                         turtle.select(slot)
  77.                         turtle.dropDown()
  78.                     end
  79.                 end
  80.             else
  81.                 for slot=4, 16 do
  82.                     turtle.select(slot)
  83.                     turtle.dropUp()
  84.                 end
  85.             end
  86.         end
  87.     end
  88.     if useTorch then
  89.         if i == torchInterval then
  90.             torchInterval = torchInterval+torchInterval
  91.             turtle.select(torchSlot)
  92.             if turtle.getItemCount(torchSlot) != 0 then
  93.                 turtle.placeDown()
  94.             else
  95.                 turtle.down()
  96.                 while turtle.getItemCount(torchSlot) < torchNeeded do
  97.                     shell.run("clear")
  98.                     print("Torches needed, Will resume when replenished.")
  99.                     print("Would need " .. torchNeeded .. "torches.")
  100.                     sleep(3)
  101.                 end
  102.                 shell.run("clear")
  103.                 turtle.up()
  104.                 print("here we go again.")
  105.             end
  106.             turtle.select(4)
  107.         end
  108.     end
  109. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement