Advertisement
Frayna

Mine v0.22

Sep 12th, 2015
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.24 KB | None | 0 0
  1. -- DECLARATIONS ->
  2. function print_inv()
  3.     for i=1 , 16 do
  4.         local data = turtle.getItemDetail(i)
  5.         turtle.select(i)
  6.             if turtle.getItemDetail(i) ~= nil then
  7.                 print("Slot " .. i .." : " .. data.count .. " " .. data.name)
  8.             else
  9.                 print("Slot " .. i .." : Empty !")
  10.             end
  11.         end
  12. turtle.select(1)
  13. end
  14. --[[
  15. function organise()
  16.     for i=1 , 16 do
  17.     j = i
  18.         local data = turtle.getItemDetail(i)
  19.         turtle.select(i + 1)
  20.             if turtle.getItemDetail(i) == nil then
  21.                 turtle.transferTo(j)
  22.             end
  23.         end
  24. turtle.select(1)
  25. end
  26. ]]
  27. function ft_fwd(nb)
  28. i = 0
  29.     while i<nb do
  30.     local success, data = turtle.inspect()
  31.         if success then
  32.         turtle.dig()
  33.         turtle.forward()
  34.         else
  35.         turtle.forward()
  36.         end
  37.     i = i+1
  38.     end
  39. end
  40.  
  41. function ft_impr ()
  42. ft_fwd(1)
  43. turtle.turnRight()
  44. ft_fwd(2)
  45. end
  46.  
  47. function ft_pair ()
  48. ft_fwd(2)
  49. turtle.turnLeft()
  50. ft_fwd(1)
  51. end
  52.  
  53. function clean()
  54.     for i=1 , 16 do
  55.         local data = turtle.getItemDetail(i)
  56.         if turtle.getItemDetail(i) ~= nil then
  57.             if i == 1 then
  58.                 turtle.select(i)
  59.                 turtle.dropDown(data.count - 1)
  60.             elseif ((data.name == "minecraft:cobblestone") or (data.name == "minecraft:dirt")) then
  61.                 turtle.select(i)
  62.                 turtle.dropDown()
  63.             end
  64.         end
  65.     end
  66. turtle.select(1)
  67. end
  68.  
  69. function mine()
  70.  turtle.digDown()
  71.  
  72.  local success, data = turtle.inspectDown()
  73.  
  74.  if ((success ~= true) or (data.name == "minecraft:flowing_lava") or (data.name == "minecraft:flowing_water")) then
  75.     turtle.down()
  76.     mine()
  77.     turtle.up()
  78.   end
  79.  
  80.   for i=1, 4
  81.   do
  82.     turtle.turnRight()
  83.     local success, data = turtle.inspect()
  84.  
  85.     if success then
  86.       print(data.name)
  87.       if ((data.name ~= "minecraft:stone") and (data.name ~= "minecraft:grass")
  88.       and (data.name ~= "minecraft:dirt") and (data.name ~= "TConstruct:GravelOre")
  89.       and (data.name ~= "minecraft:sand"))
  90.         then turtle.dig()
  91.       end
  92.     else
  93.       print("minecraft:air")
  94.     end
  95.   end
  96. end
  97.  
  98. -- MAIN ->
  99. turtle.select(1)
  100. print ("Attention !!! Ne prend pas en compte le surplus !!!")
  101. print ("Please define X")
  102. xmax = tonumber(read())
  103. print ("Please define Y")
  104. ymax = tonumber(read())
  105. print ("Press F3 and write the value of Y")
  106. height = tonumber(read())
  107. cl = true
  108. choice = " "
  109. while ((choice ~= "y") and (choice ~= "n")) do
  110. print ("Do you want eject the scrap (y/n)?")
  111. choice = read()
  112.     if choice == "n" then
  113.         cl = false
  114.     elseif choice == "y" then
  115.         cl = true
  116.     else
  117.     print("y or n expected !")
  118.     end
  119. end
  120. fuel = turtle.getFuelLevel()
  121. fneed = 3 * height * xmax * ymax
  122. print ("Estimated fuel required : " ..fneed)
  123. os.sleep(2)
  124. while fuel < fneed do
  125.     print ("Put Fuel in slot 1\nStill Requiring : " ..(fneed - fuel))
  126.     os.sleep(4)
  127.     turtle.refuel()
  128.     fuel = turtle.getFuelLevel()
  129.     turtle.select(1)
  130. end
  131. x = 1
  132. y = 1
  133. while ((x <= xmax) and (y <= ymax)) do
  134.     mine()
  135.     clean()
  136.     turtle.placeDown()
  137.         if ((x == xmax) and (y%2 == 0)) then
  138.             if xmax%2 == 1 then turtle.turnRight() end
  139.             ft_impr()
  140.             x = 1
  141.             y = y + 1
  142.         elseif ((x == xmax) and (y%2 == 1)) then
  143.             if xmax%2 == 0 then turtle.turnLeft() end
  144.             ft_pair()
  145.             turtle.turnLeft()
  146.             x = 1
  147.             y = y + 1
  148.         elseif x%2 == 1 then
  149.             ft_impr()
  150.             x = x + 1
  151.         elseif x%2 == 0 then
  152.             ft_pair()
  153.             x = x + 1
  154.         else print("EXTERMINATE !!!")
  155.         end
  156. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement