Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Advanced Ore Finder by TheAbyss
- -- V 1.0
- -- Config
- local program = "Advanced Orefinder"
- local version = "v1.0"
- local author = "TheAbyss"
- local tSave = {}
- local ores_mined, tCordsInput, select, screenw, screenh, fuel_level, _sFile
- screenw,screenh = term.getSize()
- -- Functions
- local loc = {}
- loc = {
- paused = false,
- x = 0,
- y = 0,
- z = 0,
- facing = 0,
- facingToAxis = {
- [0] = {axis = 'z', unit = 1},
- [1] = {axis = 'x', unit = -1},
- [2] = {axis = 'z', unit = -1},
- [3] = {axis = 'x', unit = 1}
- },
- pause = function()
- while loc.paused do
- sleep(1)
- end
- end,
- getAxisForFacing = function()
- return loc.facingToAxis[loc.facing]['axis'], loc.facingToAxis[loc.facing]['unit']
- end,
- turnLeft = function()
- loc.pause()
- loc.facing=(loc.facing - 1) % 4
- turtle.turnLeft()
- end,
- turnRight = function()
- loc.pause()
- loc.facing = (loc.facing + 1) % 4
- turtle.turnRight()
- end,
- moveForward = function()
- loc.pause()
- if turtle.forward() then
- local axis, unit = loc.getAxisForFacing()
- loc[axis] = loc[axis] + unit
- return true
- end
- return false
- end,
- moveBack = function()
- loc.pause()
- if turtle.back() then
- local axis, unit = loc.getAxisForFacing()
- loc[axis] = loc[axis] - unit
- return true
- end
- return false
- end,
- face = function(faceto)
- local dirdif = (faceto - loc.facing) % 4
- if dirdif == 1 then
- loc.turnRight()
- elseif dirdif == 2 then
- loc.turnRight()
- loc.turnRight()
- elseif dirdif == 3 then
- loc.turnLeft()
- end
- end,
- movez = function(d)
- if d < loc.z then loc.face(2) elseif d > loc.z then loc.face(0) end
- return loc.moveForward()
- end,
- movex = function(d)
- if d < loc.x then loc.face(1) elseif d > loc.x then loc.face(3) end
- return loc.moveForward()
- end,
- movey = function(d)
- if d < loc.y then
- return loc.moveDown()
- end
- return loc.moveUp()
- end,
- moveUp = function()
- loc.pause()
- if turtle.up() then
- loc.y = loc.y + 1
- return true
- end
- return false
- end,
- moveDown = function()
- loc.pause()
- if turtle.down() then
- loc.y = loc.y - 1
- return true
- end
- return false
- end,
- moveTo = function(x,y,z,facing)
- if y > loc.y then
- while loc.y < y do
- while not loc.moveUp() do
- if turtle.detectUp() then
- turtle.select(1)
- turtle.digUp()
- else
- turtle.attackUp()
- end
- end
- end
- end
- while x ~= loc.x do
- while not loc.movex(x) do
- if turtle.detect() then
- turtle.select(1)
- turtle.dig()
- else
- turtle.attack()
- end
- end
- end
- while z ~= loc.z do
- while not loc.movez(z) do
- if turtle.detect() then
- turtle.select(1)
- turtle.dig()
- else
- turtle.attack()
- end
- end
- end
- if y < loc.y then
- while loc.y > y do
- while not loc.moveDown() do
- if turtle.detectDown() then
- turtle.select(1)
- turtle.digDown()
- else
- turtle.attackDown()
- end
- end
- end
- end
- loc.face(facing)
- return true
- end,
- moveToPos = function(pos)
- return loc.moveTo(pos.x,pos.y,pos.z,pos.facing)
- end,
- distanceToPos = function(pos)
- return loc.fistanceTo(pos.x, pos.y, pos.z)
- end
- }
- -- Orefinder
- function saveTable(table,name)
- local file = fs.open(name,"w")
- file.write(textutils.serialize(table))
- file.close()
- end
- function loadTable(name)
- local file = fs.open(name,"r")
- local data = file.readAll()
- file.close()
- return textutils.unserialize(data)
- end
- function moveDown(h)
- while not loc.movey(h) do
- if turtle.detectDown() then
- turtle.digDown()
- if turtle.detectDown() then
- return false
- end
- else
- turtle.attackDown()
- end
- end
- return true
- end
- function compareForward(a, b)
- loc.pause()
- for i=a,b do
- turtle.select(i)
- if turtle.compare() then
- return false
- end
- end
- return true
- end
- function findDown(d)
- if not d then d = loc.y end
- local h = loc.y - d
- while loc.y ~= h do
- if not moveDown(h) then
- break
- end
- for j=1,4 do
- if compareForward(1, t.Save.ignore) then
- if not space() then
- returnToChest()
- end
- turtle.select(1)
- turtle.dig()
- ores_mined = ores_mined + 1
- end
- loc.turnRight()
- end
- end
- end
- function refuel(ammount)
- if turtle.getFuelLevel()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement