JWSTelescope

Untitled

May 1st, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.76 KB | None | 0 0
  1. function clearInv()
  2.   for i=1,16 do
  3.    turtle.select(i)
  4.    turtle.drop()
  5.   end
  6.   turtle.select(1)
  7. end
  8.  
  9. function getItem(itemName, itemSpotNumber)
  10.   clearInv()
  11.   isCoal = false
  12.   coalSlot = 0
  13.   i = 1
  14.   while not isCoal do
  15.     turtle.select(i)
  16.     turtle.suck()
  17.     data = turtle.getItemDetail()
  18.     if data.name == itemName then
  19.       isCoal = true
  20.     end
  21.     i = i+1
  22.   end
  23.   coalSlot = i
  24.   for i=i-2, 1, -1 do
  25.     turtle.select(i)
  26.     turtle.drop()
  27.   end
  28.   turtle.select(coalSlot-1)
  29.   turtle.transferTo(itemSpotNumber)
  30.   turtle.select(1)
  31. end
  32.  
  33. function gatherDiamond()
  34.   for i = 1, 4 do
  35.     turtle.turnLeft()
  36.     result, data = turtle.inspect()
  37.     if result and data.name == "minecraft:diamond_ore" then
  38.       while turtle.dig() do
  39.         print("Digging!")
  40.       end
  41.       turtle.suck()
  42.       turtle.forward()
  43.       gatherDiamond()
  44.       turtle.back()
  45.     end
  46.   end
  47.   result, data = turtle.inspectUp()
  48.   if result and data.name == "minecraft:diamond_ore" then
  49.     while turtle.digUp() do
  50.       print("digging up!")
  51.     end
  52.     turtle.up()
  53.     gatherDiamond()
  54.     turtle.down()
  55.   end
  56.   result1, data1 = turtle.inspectDown()
  57.   if result1 and data1.name == "minecraft:diamond_ore" then
  58.     while turtle.digDown() do
  59.       print("digging down!")
  60.     end
  61.     turtle.down()
  62.     gatherDiamond()
  63.     turtle.up()
  64.   end
  65. end
  66.  
  67. function placeTorch()
  68.   turtle.select(2)
  69.   turtle.turnLeft()
  70.   turtle.placeUp()
  71.   turtle.turnRight()
  72. end
  73.  
  74. function digMultipleTimes(times)
  75.   for i = 1, times do
  76.     gatherDiamond()
  77.    
  78.     while not turtle.up() do
  79.         turtle.digUp()
  80.     end
  81.     gatherDiamond()
  82.     while true do
  83.       if not turtle.dig() then
  84.         break
  85.       end
  86.     end
  87.     turtle.down()
  88.     if i % 5 == 0 then
  89.       placeTorch()
  90.     end
  91.     while not turtle.forward() do
  92.       turtle.dig()
  93.     end
  94.   end
  95. end
  96.  
  97.  
  98. function digTunnel()
  99.     digMultipleTimes(100)
  100.     turtle.turnRight()
  101.     digMultipleTimes(4)
  102.     turtle.turnRight()
  103.     digMultipleTimes(100)
  104. end
  105.  
  106. function go(i)
  107.   for j = 1, i do
  108.     while true do
  109.       if not turtle.dig() then
  110.         break
  111.       end
  112.     end
  113.     turtle.up()
  114.     while not turtle.forward() do
  115.       turtle.dig()
  116.     end
  117.     turtle.down()
  118.   end
  119. end
  120.  
  121. function mine()
  122.   while true do
  123.     i = 0
  124.     while turtle.getFuelLevel() < 1000 do
  125.       getItem("minecraft:coal", 1)
  126.       turtle.refuel()
  127.     end
  128.     turtle.select(2)
  129.     while turtle.getItemCount() < 50 do
  130.       getItem("minecraft:torch", 2)
  131.     end
  132.     turtle.turnRight()
  133.     turtle.turnRight()
  134.     turtle.forward()
  135.     i = i + 1
  136.     turtle.turnLeft()
  137.     result, data = turtle.inspect()
  138.     while not result do
  139.       turtle.turnRight()
  140.       go(8)
  141.       i = i + 8
  142.       turtle.turnLeft()
  143.       result, data = turtle.inspect()
  144.     end
  145.     digTunnel()
  146.     turtle.turnRight()
  147.     go(4)
  148.     for j = 1, i do
  149.       turtle.forward()
  150.     end
  151.   end
  152. end
  153.  
  154. mine()
Add Comment
Please, Sign In to add comment