Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.loadAPI("Lib/move")
- args = {...}
- banList = {"stone", "dirt", "gravel"}
- retPoint = {x = 0, y = 0, z = 0, h = 0}
- --Set minHeight to 4 to get bedrock layer.
- minHeight = 4
- function splitString(str)
- return string.sub(str, 11, #str)
- end
- function checkFull()
- for i = 1, 16 do
- if turtle.getItemCount(i) == 0 then
- return false
- end
- end
- return true
- end
- function checkFront()
- local s, d = turtle.inspect()
- if not s then return false end
- local name = splitString(d.name)
- for i = 1, #banList do
- if name == banList[i] then
- return false
- end
- end
- turtle.dig()
- move.report("Treasure found!")
- end
- function setReturnPoint()
- retPoint = {
- x = move.data.pos.x,
- y = move.data.pos.y,
- z = move.data.pos.z,
- h = move.data.pos.h,
- }
- end
- function branch(length)
- for i = 1, length do
- if checkFull() then
- setReturnPoint()
- move.toNoSafety(move.getTarget())
- move.unload(true)
- move.findZ(retPoint.z)
- move.findX(retPoint.x)
- move.face(retPoint.h)
- end
- move.fd(1, true)
- move.rt(1)
- checkFront()
- move.lt(2)
- checkFront()
- move.rt(1)
- end
- move.rt(2)
- move.fd(length, true)
- end
- function trunk(length, bLength)--Length is multiplied by three to mean how many branches you want.
- move.setReturnPoint()
- for i = 1, length do
- move.report("Starting Trunk Segment "..i..".")
- move.fd(3, true)
- move.rt(1)
- branch(bLength)
- branch(bLength)
- move.lt(1)
- move.report("Trunk Segment "..i.." complete.")
- end
- move.rt(2)
- move.fd(length * 3)
- move.rt(2)
- move.report("Trunk complete.")
- end
- function mine(tLen, bLen, yLevels)
- for i = 1, yLevels do
- move.report("Mining layer "..i)
- move.findY(minHeight + i, true)
- trunk(tLen, bLen)
- end
- move.to(move.home.x, move.home.y, move.home.z, move.home.h)
- end
- mine(tonumber(args[1]), tonumber(args[2]), tonumber(args[3]))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement