Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function isOre(mod)
- mod = mod or ""
- local success, data = turtle["inspect"..mod]()
- if success and string.find(string.lower(data.name),"ore") then
- print(data.name) -- ore name (minecraft:redstone_ore, or something like that)
- return true
- end
- return false
- end
- function mineOre(dir,tStack)
- dir = dir or "forward" --will only be forward, top, or bottom
- tStack = tStack or {}
- local level = 0
- if dir == "top" then
- turtle.digUp()
- turtle.up()
- table.insert(tStack,"up")
- level = level + 1
- elseif dir == "bottom" then
- turtle.digDown()
- turtle.down()
- table.insert(tStack,"down")
- level = level + 1
- elseif dir == "forward" then
- turtle.dig()
- turtle.forward()
- table.insert(tStack,"forward")
- level = level + 1
- end
- if isOre("Up") then
- print("Spawning top instance")
- mineOre("top",tStack)
- end
- if isOre("Down") then
- print("Spawning bottom instance")
- mineOre("bottom",tStack)
- end
- if isOre() then
- print("Spawning forward instance")
- mineOre("forward",tStack)
- end
- for i=1,3 do
- turtle.turnLeft()
- table.insert(tStack,"left")
- level = level + 1
- if isOre() then
- mineOre("forward",tStack)
- end
- end
- turtle.turnLeft()
- table.insert(tStack,"left")
- level = level + 1
- for i=1,level do
- if tStack[#tStack]=="left" then
- turtle.turnRight()
- elseif tStack[#tStack]=="forward" then
- turtle.back()
- elseif tStack[#tStack]=="up" then
- turtle.down()
- elseif tStack[#tStack]=="down" then
- turtle.up()
- end
- table.remove(tStack,#tStack)
- end
- end
- mineOre()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement