Advertisement
incinirate

Ore

Apr 26th, 2015
344
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.54 KB | None | 0 0
  1. function isOre(mod)
  2.     mod = mod or ""
  3.     local success, data = turtle["inspect"..mod]()
  4.     if success and string.find(string.lower(data.name),"ore") then
  5.         print(data.name)  --  ore name (minecraft:redstone_ore, or something like that)
  6.         return true
  7.     end
  8.     return false
  9. end
  10.  
  11. function mineOre(dir,tStack)
  12.     dir = dir or "forward" --will only be forward, top, or bottom
  13.     tStack = tStack or {}
  14.  
  15.     local level = 0
  16.     if dir == "top" then
  17.         turtle.digUp()
  18.         turtle.up()
  19.         table.insert(tStack,"up")
  20.         level = level + 1
  21.     elseif dir == "bottom" then
  22.         turtle.digDown()
  23.         turtle.down()
  24.         table.insert(tStack,"down")
  25.         level = level + 1
  26.     elseif dir == "forward" then
  27.         turtle.dig()
  28.         turtle.forward()
  29.         table.insert(tStack,"forward")
  30.         level = level + 1
  31.     end
  32.    
  33.     if isOre("Up") then
  34.         print("Spawning top instance")
  35.         mineOre("top",tStack)
  36.     end
  37.     if isOre("Down") then
  38.         print("Spawning bottom instance")
  39.         mineOre("bottom",tStack)
  40.     end
  41.     if isOre() then
  42.         print("Spawning forward instance")
  43.         mineOre("forward",tStack)
  44.     end
  45.     for i=1,3 do
  46.         turtle.turnLeft()
  47.         table.insert(tStack,"left")
  48.         level = level + 1
  49.         if isOre() then
  50.             mineOre("forward",tStack)
  51.         end
  52.     end
  53.     turtle.turnLeft()
  54.     table.insert(tStack,"left")
  55.     level = level + 1
  56.     for i=1,level do
  57.         if tStack[#tStack]=="left" then
  58.             turtle.turnRight()
  59.         elseif tStack[#tStack]=="forward" then
  60.             turtle.back()
  61.         elseif tStack[#tStack]=="up" then
  62.             turtle.down()
  63.         elseif tStack[#tStack]=="down" then
  64.             turtle.up()
  65.         end
  66.         table.remove(tStack,#tStack)
  67.     end
  68. end
  69. mineOre()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement