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 = {}
- orestack = Stack:Create()
- -- Create a Table with stack functions
- function Stack:Create()
- -- stack table
- local t = {}
- -- entry table
- t._et = {}
- -- push a value on to the stack
- function t:push(...)
- if ... then
- local targs = {...}
- -- add values
- for _,v in ipairs(targs) do
- table.insert(self._et, v)
- end
- end
- end
- -- pop a value from the stack
- function t:pop(num)
- -- get num values from stack
- local num = num or 1
- -- return table
- local entries = {}
- -- get values into entries
- for i = 1, num do
- -- get last entry
- if #self._et ~= 0 then
- table.insert(entries, self._et[#self._et])
- -- remove last value
- table.remove(self._et)
- else
- break
- end
- end
- -- return unpacked entries
- return unpack(entries)
- end
- -- get entries
- function t:getn()
- return #self._et
- end
- -- list values
- function t:list()
- for i,v in pairs(self._et) do
- print(i, v)
- end
- end
- return t
- end
- -- CHILLCODE™
- 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(1)
- 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