Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- file = fs.open("Choords", "r")
- c = textutils.unserialize(file.readAll())
- file.close()
- digging = true
- blacklist = {"minecraft:grass", "minecraft:cobblestone", "minecraft:stone", "minecraft:dirt", "minecraft:gravel", "minecraft:sand"}
- zDiff = {-1, 0, 1, 0}
- xDiff = {0, 1, 0, -1}
- function saveChoords()
- file = fs.open("Choords", "w")
- file.write(textutils.serialize(c))
- file.close()
- end
- function down()
- tryes = 0
- while not turtle.down() do
- turtle.digDown()
- tryes = tryes + 1
- if tryes > 5 then
- digging = false
- exitHole()
- end
- end
- c.y = c.y - 1
- saveChoords()
- end
- function forward()
- while not turtle.forward() do
- turtle.dig()
- end
- c.x = c.x + xDiff[c.o]
- c.z = c.z + zDiff[c.o]
- saveChoords()
- end
- function right()
- turtle.turnRight()
- c.o = c.o + 1
- if c.o > 4 then
- c.o = 1
- end
- saveChoords()
- end
- function left()
- turtle.turnLeft()
- c.o = c.o - 1
- if c.o < 1 then
- c.o = 4
- end
- saveChoords()
- end
- function up()
- while not turtle.up() do
- turtle.digUp()
- end
- c.y = c.y + 1
- saveChoords()
- end
- function checkBlock()
- f, block = turtle.inspect()
- if block ~= nil then
- mine = true
- for i = 1,#blacklist do
- if block.name == blacklist[i] then
- mine = false
- end
- end
- if mine then
- turtle.dig()
- end
- end
- end
- function digLayer()
- down()
- checkBlock()
- for i = 1,3 do
- right()
- checkBlock()
- end
- end
- function look(o)
- while c.o ~= o do
- right()
- end
- end
- function exitHole()
- while c.y < 65 do
- up()
- end
- for i = 1,16 do
- turtle.select(i)
- item = turtle.getItemDetail(i)
- if item ~= nil then
- drop = false
- for i = 1,#blacklist do
- if item.name == blacklist[i] then
- drop = true
- end
- end
- if drop then
- turtle.dropDown()
- end
- end
- end
- look(1)
- forward()
- forward()
- left()
- forward()
- c.pos = c.pos - 1
- if c.pos < 0 then
- look(2)
- for i = 1,c.maxPos+2 do
- forward()
- end
- left()
- for i = 1,c.maxPos/2+1 do
- forward()
- end
- c.pos = c.maxPos
- end
- saveChoords()
- end
- function hole()
- digging = true
- while digging do
- digLayer()
- end
- end
- hole()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement