Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local history = {}
- local keep = {
- "minecraft:iron_ore",
- "minecraft:coal_ore",
- "minecraft:diamond_ore",
- "minecraft:redstone_ore",
- "minecraft:gold_ore"
- }
- local miningMode = true
- local stopMoving = false
- turtle.select(1)
- turtle.refuel()
- function hasval(tbl, val)
- for i,v in ipairs(tbl) do
- if v == val then
- return true
- end
- end
- return false
- end
- function checkore()
- for i=1,16 do
- turtle.select(i)
- local idata = turtle.getItemDetail()
- if idata then
- if hasval(keep, idata.name) == false then
- turtle.drop()
- end
- end
- end
- end
- function postmove()
- checkore()
- if turtle.getFuelLevel() == table.getn(history) then
- gohome()
- end
- end
- function fwd()
- if stopMoving then
- return false
- end
- if miningMode then
- if turtle.detect() then
- turtle.dig()
- end
- end
- table.insert(history, "f")
- turtle.forward()
- postmove()
- end
- function left()
- if stopMoving then
- return false
- end
- turtle.turnLeft()
- if miningMode then
- if turtle.detect() then
- turtle.dig()
- end
- end
- table.insert(history, "l")
- turtle.forward()
- postmove()
- end
- function right()
- if stopMoving then
- return false
- end
- table.insert(history, "r")
- turtle.turnRight()
- if miningMode then
- if turtle.detect() then
- turtle.dig()
- end
- end
- turtle.forward()
- postmove()
- end
- function down()
- if stopMoving then
- return false
- end
- table.insert(history, "d")
- if miningMode then
- if turtle.detectDown() then
- turtle.digDown()
- end
- end
- turtle.down()
- postmove()
- end
- function up()
- if stopMoving then
- return false
- end
- turtle.insert(history, "u")
- if miningMode then
- if turtle.detectUp() then
- turtle.digUp()
- end
- end
- turtle.up()
- postmove()
- end
- function gohome()
- stopMoving = true
- for i=table.getn(history), 1,-1 do
- local event = history[i]
- print(event)
- if event == "f" then
- turtle.back()
- elseif event == "l" then
- turtle.back()
- turtle.turnRight()
- elseif event == "r" then
- turtle.back()
- turtle.turnLeft()
- elseif event == "u" then
- turtle.down()
- elseif event == "d" then
- turtle.up()
- end
- end
- end
- fwd()
- for z=1,3 do
- down()
- for y=1,5 do
- fwd()
- end
- right()
- for x=1,4 do
- fwd()
- end
- right()
- right()
- for x=1,4 do
- fwd()
- end
- left()
- left()
- for x=1,4 do
- fwd()
- end
- right()
- right()
- for x=1,4 do
- fwd()
- end
- left()
- left()
- for x=1,4 do
- fwd()
- end
- right()
- right()
- for x=1,4 do
- fwd()
- end
- turtle.turnRight()
- end
- gohome()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement