Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function isblock_f(id)
- local success, data = turtle.inspect()
- if success then
- if id == data.name then
- return true
- end
- end
- end
- function isblock_l(id)
- turtle.turnLeft()
- local success, data = turtle.inspect()
- turtle.turnRight()
- if success then
- if id == data.name then
- return true
- end
- end
- end
- function isblock_r(id)
- turtle.turnRight()
- local success, data = turtle.inspect()
- turtle.turnLeft()
- if success then
- if id == data.name then
- return true
- end
- end
- end
- function isblock_u(id)
- local success, data = turtle.inspectUp()
- if success then
- if id == data.name then
- return true
- end
- end
- end
- function isblock_d(id)
- local success, data = turtle.inspectDown()
- if success then
- if id == data.name then
- return true
- end
- end
- end
- function isblock_b(id)
- turtle.turnLeft()
- turtle.turnLeft()
- local success, data = turtle.inspect()
- turtle.turnRight()
- turtle.turnRight()
- if success then
- if id == data.name then
- return true
- end
- end
- end
- -- Stack Table
- -- Uses a table as stack, use <table>:push(value) and <table>:pop()
- -- Lua 5.1 compatible
- -- GLOBAL
- Stack = Core.class()
- function Stack:init(list)
- if not list then
- -- create an empty stack
- self.stack = {}
- else
- -- initialise the stack
- self.stack = list
- end
- end
- function Stack:push(item)
- -- put an item on the stack
- self.stack[#self.stack+1] = item
- end
- function Stack:pop()
- -- make sure there's something to pop off the stack
- if #self.stack > 0 then
- -- remove item (pop) from stack and return item
- return table.remove(self.stack, #self.stack)
- end
- end
- function Stack:iterator()
- -- wrap the pop method in a function
- return function()
- -- call pop to iterate through all items on a stack
- return self:pop()
- end
- end
- orestack = Stack.new()
- function minevein(id)
- if isblock_f(id) then
- print("f")
- turtle.dig()
- orestack:push("f")
- turtle.forward()
- return minevein(id)
- end
- if isblock_u(id) then
- print("u")
- turtle.digUp()
- orestack:push("u")
- turtle.up()
- return minevein(id)
- end
- if isblock_d(id) then
- print("d")
- turtle.digDown()
- orestack:push("d")
- turtle.down()
- return minevein(id)
- end
- turtle.turnLeft()
- if isblock_f(id) then
- print("l")
- turtle.dig()
- orestack:push("l")
- turtle.forward()
- return minevein(id)
- end
- turtle.turnLeft()
- if isblock_f(id) then
- print("b")
- turtle.dig()
- orestack:push("b")
- turtle.forward()
- return minevein(id)
- end
- turtle.turnLeft()
- if isblock_f(id) then
- print("r")
- turtle.dig()
- orestack:push("r")
- turtle.forward()
- return minevein(id)
- end
- last_mov = orestack:pop()
- if last_mov then
- if last_mov == "u" then
- turtle.down()
- return minevein(id)
- elseif last_mov == "d" then
- turtle.up()
- return minevein(id)
- else
- turtle.back()
- return minevein(id)
- end
- end
- end
- turtle.refuel(5)
- print(turtle.getFuelLevel())
- minevein("minecraft:dirt")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement