Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.loadAPI("grey_api/move.lua")
- os.loadAPI("grey_api/util.lua")
- local start_depth = 16 --go down this many blocks before digging
- local length = 16 --strip length in blocks - forward
- local width = 1 --number of strips- right
- local height = 1 -- number of levels of strips - down
- local current_width = width
- local current_height = height
- local floor_spacing = 5
- local fuels = {"minecraft:coal"}
- local minimum_fuel_level = util.max(100, start_depth, length, width, height)
- local important_ores = {["minecraft:coal"]=true,["minecraft:diamond_ore"]=true,["minecraft:iron_ore"]=true,["minecraft:redstone_ore"]=true,["minecraft:gold_ore"]=true,["minecraft:lapis_ore"]=true}
- --tests block in direction dir.
- --if block["name"] is in important_ores
- function test(dir)
- dir = dir or "forward" --can be forward, up or down
- local b,block = nil
- if dir=="up" then
- b,block = turtle.inspectUp()
- elseif dir=="down" then
- b,block = turtle.inspectDown()
- else
- b,block = turtle.inspect()
- end
- if b and important_ores[block["name"]] then
- print("Found Vein of "..block["name"])
- return dig_vein(dir)
- else
- if dir=="up" then
- return turtle.digUp()
- elseif dir=="down" then
- return turtle.digDown()
- else
- return turtle.dig()
- end
- end
- end
- function dig_home(go_x,go_y,go_z,go_face)
- if go_x==nil then
- go_x = true
- end
- if go_y==nil then
- go_y = true
- end
- if go_z==nil then
- go_z = true
- end
- if go_face==nil then
- go_face = true
- end
- local _x = move.get_x()
- local _y = move.get_y()
- local _z = move.get_z()
- --go x
- if go_x then
- if _x > 0 then
- move.face(2)
- else
- move.face(0)
- end
- for i=1,util.abs(_x) do
- test()
- move.go()
- test("up")
- test("down")
- end
- end
- --go z
- if go_z then
- if _z > 0 then
- move.face(3)
- else
- move.face(1)
- end
- for i=1,util.abs(_z) do
- test()
- move.go()
- test("up")
- test("down")
- end
- end
- --go y
- if go_y then
- for i=1,util.abs(_y) do
- if _y>0 then
- test("down")
- move.go("down")
- else
- test("up")
- move.go("up")
- end
- end
- end
- --go face
- if go_face then
- move.face(0)
- end
- end
- function dig_vein(dir, block_name)
- dir = dir or "forward" --can be forward, up or down
- return true
- end
- function refuel()
- while turtle.getFuelLevel()<=minimum_fuel_level and util.fuel(1,fuels) do end
- if turtle.getFuelLevel()<=0 then
- print("out of fuel")
- return false
- elseif turtle.getFuelLevel()<=minimum_fuel_level then
- print("low on fuel")
- end
- return true
- end
- function mine_line()
- if not refuel() then return false end
- test()
- move.go()
- test("down")
- test("up")
- return not util.is_full()
- end
- function mine_turn()
- if not refuel() then return false end
- local old_facing = move.get_facing()
- move.face(1)
- for i=1,3 do
- test()
- move.go()
- test("up")
- test("down")
- end
- if old_facing==0 then
- move.face(2)
- elseif old_facing==2 then
- move.face(0)
- end
- return true
- end
- function mine_down()
- if not refuel() then return false end
- current_width = width
- dig_home(true,false,true,true)
- for i=1,floor_spacing do
- test("down")
- move.go("down",1)
- end
- test("down")
- return true
- end
- function mine()
- --mine down to start height
- refuel()
- for i=1,start_depth do
- test("down")
- move.go("down")
- end
- test("down")
- while true do
- for i=1,length-1 do
- mine_line()
- end
- current_width = current_width-1
- if current_width<=0 then
- current_height = current_height-1
- if current_height <= 0 then
- print("done")
- dig_home()
- break
- else
- mine_down()
- end
- else
- mine_turn()
- end
- end
- end
- if length<=0 or width<=0 or height<=0 then print("invalid strip mine dimensions") return false end
- move.reset_position()
- mine()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement