Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function has_value (tab, val)
- for index, value in ipairs(tab) do
- if value == val then
- return true
- end
- end
- return false
- end
- function refuel()
- if turtle.getFuelLevel() < 10 then
- print("Refueling")
- turtle.select(1)
- turtle.refuel(1)
- end
- end
- retrace = {}
- rares = {"minecraft:diamond_ore"}
- print("Excavating ore vein")
- while true do
- refuel()
- path_found = false
- a, b = turtle.inspect()
- if a then print("Forward found " .. b.name) end
- if a and has_value(rares, b.name) then
- print("Ore found forwards")
- turtle.dig()
- turtle.forward()
- table.insert(retrace, "back")
- path_found = true
- else
- a, b = turtle.inspectUp()
- if a then print("Up found " .. b.name) end
- if a and has_value(rares, b.name) then
- print("Ore found up")
- turtle.digUp()
- turtle.up()
- table.insert(retrace, "down")
- path_found = true
- else
- a, b = turtle.inspectDown()
- if a then print("Down found " .. b.name) end
- if a and has_value(rares, b.name) then
- print("Ore found down")
- turtle.digDown()
- turtle.down()
- table.insert(retrace, "up")
- path_found = true
- end
- end
- end
- end
- for i, command in ipairs(retrace) do
- print("Retracing, command: " .. command)
- refuel()
- if command == "up" then turtle.up() end
- if command == "down" then turtle.down() end
- if command == "left" then turtle.left() end
- if command == "right" then turtle.right() end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement