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 dig_blocs()
- if turtle.detect() == true then
- turtle.dig()
- end
- turtle.up()
- if turtle.detect() == true then
- turtle.dig()
- end
- turtle.up()
- if turtle.detect() == true then
- turtle.dig()
- end
- turtle.down()
- turtle.down()
- end
- function get_back(home)
- local position = vector.new(gps.locate(5))
- turtle.turnLeft()
- turtle.turnLeft()
- while position.y ~= home.y do
- turtle.down()
- end
- position.y = home.y
- if not x then
- print("Lost")
- return 0
- end
- while position ~= home do
- 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
- function main()
- local upordown = false
- local home = gps.locate()
- local args = { ... }
- 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()
- turtle.forward()
- upordown = not upordown
- if check_level(2) < 5 then
- get_back(home)
- end
- end
- get_back(home)
- end
- main()
Add Comment
Please, Sign In to add comment