Advertisement
Guest User

stripMine2

a guest
Nov 23rd, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.35 KB | None | 0 0
  1. --constants
  2. local lava = "minecraft:lava"
  3. local flowingLava = "minecraft:flowing_lava"
  4.  
  5. local water = "minecraft:water"
  6. local flowingWater = "minecraft:flowing_water"
  7.  
  8. local stone = "minecraft:stone"
  9.  
  10. local iron = "minecraft:iron_ore"
  11. local coal = "minecraft:coal_ore"
  12. local redstone = "minecraft:redstone_ore"
  13. local diamond = "minecraft:diamond_ore"
  14.  
  15. local ores = {iron,coal,redstone,diamond}
  16. local fluids = {lava,flowingLava,water,flowingWater}
  17. --functions
  18.  
  19. --printList
  20. local function printList(list)
  21.   for _,item in pairs(list) do
  22.     print(item)
  23.   end
  24. end
  25.  
  26.  
  27. -- check for a block in front, down and up
  28. -- ex (2, "front")
  29. local function findBlock(blocksTypes, direction)
  30.   local foundBlock = false
  31.  
  32.   -- check directiom
  33.   if direction == "front" then
  34.     succes, data = turtle.inspect()
  35.   elseif direction == "up" then
  36.     succes, data = turtle.inspectUp()
  37.   elseif direction == "down" then
  38.     succes, data = turtle.inspectDown()
  39.   else
  40.     error("function: findBlock() needs direction")  
  41.   end  
  42.  
  43.   -- find block
  44.   local type = 0
  45.  
  46.   for _,blocks in pairs(blocksTypes) do
  47.     type = type + 1
  48.     for _,block in pairs(blocks) do
  49.       if succes and data.name == block then
  50.         foundBlock = type
  51.       elseif not succes then
  52.         foundBlock = -1
  53.       end
  54.     end
  55.   end
  56.  
  57.   print("BlockID",direction,":", data.name)
  58.                            
  59.   return foundBlock
  60. end
  61.  
  62.  
  63. --shaftCreate
  64. -- mines above and forward
  65. local function tunnelCreate()
  66.  
  67.   local gotFuel = true
  68.  
  69.   turtle.digUp()
  70.   turtle.dig()
  71.   succes, reason = turtle.forward()
  72.  
  73.   if succes == false then
  74.     print("Turtle didn't move")
  75.     if reason == "Out of fuel" then
  76.       gotFuel = false
  77.     elseif reason == "Movement obstructed" then
  78.       print("tumnel3(): Movement obstructed")
  79.     end
  80.   end        
  81.    
  82.   return gotFuel
  83. end
  84.  
  85.  
  86. --main
  87. local args = {...}
  88. local len = args[1]
  89. local foundBlockDown = 0
  90.  
  91. for i = 1,len do
  92.   if not tunnelCreate() then
  93.     turtle.refuel()
  94.   end
  95.  
  96.   foundBlockDown = findBlock({ores,fluids,},"down")
  97.   if foundBlockDown == 1 then
  98.     print("found a ore")
  99.   elseif foundBlockDown == 2 then
  100.     turtle.suckDown()
  101.     turtle.placeDown(1)
  102.     print("found a fluid")
  103.   elseif foundBlockDown == -1 then
  104.     print("found a gap")
  105.     turtle.placeDown(1)
  106.   end
  107.   foundBlockDown = 0
  108.    
  109. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement