Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function isfull()
- for i=1,16,1 do
- if turtle.getItemSpace(i) > 0 then
- return false
- end
- end
- return true
- end
- function digging()
- if turtle.detect() then
- local inspection = vector.new(turtle.inspect())
- while inspection.y["name"] == "minecraft:gravel" do
- inspection = vector.new(turtle.inspect())
- turtle.dig()
- end
- turtle.dig()
- end
- end
- function dig_blocs(z)
- if z[1] == 3 then
- digging()
- turtle.down()
- z[1] = z[1] - 1
- digging()
- turtle.down()
- z[1] = z[1] - 1
- digging()
- elseif z[1] == 1 then
- digging()
- turtle.up()
- z[1] = z[1] + 1
- digging()
- turtle.up()
- z[1] = z[1] + 1
- digging()
- end
- end
- function get_back(home)
- local position = vector.new(gps.locate(5))
- turtle.turnLeft()
- turtle.turnLeft()
- if not position.x then
- print("Lost")
- return 0
- end
- while position.z ~= home.z do
- turtle.down()
- position = vector.new(gps.locate())
- end
- position = vector.new(gps.locate())
- while position.x ~= home.x or position.y ~= home.y do
- position =vector.new(gps.locate())
- if turtle.getFuelLevel() < 3 then
- reload_fuel(2)
- end
- turtle.forward()
- end
- end
- function check_level(fuel_slot)
- turtle.select(fuel_slot)
- return turtle.getItemCount()
- end
- function reload_fuel(fuel_slot)
- local previous_slot = turtle.getSelectedSlot()
- turtle.select(fuel_slot)
- turtle.refuel(1)
- turtle.select(previous_slot)
- end
- local args = { ... }
- function main(args)
- local upordown = false
- local z = {1,3}
- local home = vector.new(gps.locate())
- if table.getn(args) < 1 then
- print("Depth of mining is required as arg. 1")
- return 1
- end
- local depth = tonumber(args[1])
- for i=1,depth,1 do
- if turtle.getFuelLevel() < 3 then
- reload_fuel(2)
- end
- dig_blocs(z)
- turtle.forward()
- upordown = not upordown
- if check_level(2) < 5 then
- get_back(home)
- end
- end
- get_back(home)
- end
- main(args)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement