Posted 03 February 2013 - 05:06 AM
Hello,
Ever had a volcano in your way, how about a mountain or even someone else's house?
Well this is the turtle program for you.
This turtle program will take a set of coordinates and then remove all the blocks from within those coordinates efficiently.
The the program will then drop any blocks off in a chest where it also refuels.
Features:
GPS enabled
Auto-refueling
Saves position to file
Drops off materials at drop off point.
Planned Features:
Ability to work with no GPS.
Fill gaps in floor.
Instructions:
Place a chest with some fuel inside, then south of that chest and 1 block higher place another chest, This one is for the collected resources.
Next simply run the program and use the menu to change the coordinates of the three locations.
The first coordinates are for the drop off point, this is the block above your fuel chest and north of your drop off chest.
The second set of coordinates are the x, y, z value of the start position.
The Third and final set of coordinates are the x, y, z value of the end position.
To cycle through the coordinates use the up, down, left and right arrow keys.
To set the values of the x, y, z to a negative value simply type in the value and then use the - key.
Code
Ever had a volcano in your way, how about a mountain or even someone else's house?
Well this is the turtle program for you.
This turtle program will take a set of coordinates and then remove all the blocks from within those coordinates efficiently.
The the program will then drop any blocks off in a chest where it also refuels.
Features:
GPS enabled
Auto-refueling
Saves position to file
Drops off materials at drop off point.
Planned Features:
Ability to work with no GPS.
Fill gaps in floor.
Instructions:
Spoiler
Requires GPS and a wireless turtle :)/>Place a chest with some fuel inside, then south of that chest and 1 block higher place another chest, This one is for the collected resources.
Next simply run the program and use the menu to change the coordinates of the three locations.
The first coordinates are for the drop off point, this is the block above your fuel chest and north of your drop off chest.
The second set of coordinates are the x, y, z value of the start position.
The Third and final set of coordinates are the x, y, z value of the end position.
To cycle through the coordinates use the up, down, left and right arrow keys.
To set the values of the x, y, z to a negative value simply type in the value and then use the - key.
Code
Spoiler
Available from pastebin.com @ http://pastebin.com/WEPr8Egx--[[
Author Minecraft Name: d_four
Author AKA : d4rkdr460n , bl4ckdr460n
Version: 0.3
]]--
--[[
Change Log v0.3
Fixed wrong vertical direction from save.
Change Log v0.2
Removed dual saving files.
Fixed facing wrong direction after refuel.
Fixed Not emptying inventory when full.
]]--
-- current bugs and plans for future updates ---
-- sometimes turtle faces wrong direction after refuel--
-- Clear it config area --
--Config Vars
local amountOfStripsBeforeFullInvCheck = 3 -- read the variable
local topGap = 5 -- amount of space above before moving to next spot
local minimumFuelLevel = 40 -- minimum fuel to keep as a buffer (lower = more efficient | higher = more stable)
-- Timing Vars
local gpsTimeToWait = 0.2 -- Time to wait for GPS signal (higher for slower computers)
-- Locational Vars
local cx,cy,cz = 0,0,0 -- Current Location
local currentFacing = 0 -- Current Facing Direction NESW
local distanceToFuel = 0 -- Distance away from fuel
local lastActionPositionx,lastActionPositiony,lastActionPositionz = 0,0,0 -- Last position working before leaving for nom noms
local lastActionFacing = 0 -- direction of last strip mining action
-- Program Logic Vars
local running = true -- should program run boolean
local isSetup = true -- Currently needs to be setup
local goingUp = true -- going up or down
local skipSetup = false -- skip setup (recover from crash/servershutdown,loss of chunk loading etc)
local forceCheck = false -- force a return home
local overrideNextActionFace = false
-- File Saving
local statusFile = "status.txt" -- name of the file to store current status (used to record current action allowing turtle to resume from latest point)
-- Program Logic Vars
local running = true -- should program run boolean
local isSetup = true -- Currently needs to be setup
local goingUp = true -- going up or down
local skipSetup = false -- skip setup (recover from crash/servershutdown,loss of chunk loading etc)
local forceCheck = false -- force a return home
local notAtEnd = true -- not finished mining yet
local overrideNextActionFace = false
-- debug and display vars
local currentMissionString = " Being Static " -- Current Mission [ Getting Dinner , Being Static , On The Job , moving doen etc]
local debugMode = false -- display verbose
local debugLevel = 0 -- level of debug (0=minimum, 1=variableOnly ,2=Variable+function,3=All)
local debugWriteToFile = false -- write debug to file
-- KEY MAP -------------------------------------
local keys = {}
keys[2] = 1
keys[3] = 2
keys[4] = 3
keys[5] = 4
keys[6] = 5
keys[7] = 6
keys[8] = 7
keys[9] = 8
keys[10] = 9
keys[11] = 0
keys[79] = 1
keys[80] = 2
keys[81] = 3
keys[75] = 4
keys[76] = 5
keys[77] = 6
keys[71] = 7
keys[72] = 8
keys[73] = 9
keys[82] = 0
keys[28] = "Enter"
keys[200] = "Up"
keys[203] = "Left"
keys[205] = "Right"
keys[208] = "Down"
-- COORD LOCATIONS -----------------------------
local coords = {}
coords[1] = {{["x"]=21, ["y"]=5, ["var"] = 0},
{["x"]=28, ["y"]=5, ["var"] = 0},
{["x"]=35, ["y"]=5, ["var"] = 0}}
coords[2] = {{["x"]=21, ["y"]=6, ["var"] = 0},
{["x"]=28, ["y"]=6, ["var"] = 0},
{["x"]=35, ["y"]=6, ["var"] = 0}}
coords[3] = {{["x"]=21, ["y"]=7, ["var"] = 0},
{["x"]=28, ["y"]=7, ["var"] = 0},
{["x"]=35, ["y"]=7, ["var"] = 0}}
-- FUNCTIONS -----------------------------------
function checkFuel()
debugInfo("checking Fuel", 2)
if(turtle.getFuelLevel() < (getDistanceTofuel()+minimumFuelLevel)) or forceCheck == true then
forceCheck = false
GoToLocation(coords[1][1]["var"],coords[1][2]["var"],coords[1][3]["var"])
Turn(1)
for i=1,16 do
turtle.select(i) -- select slot
turtle.drop() -- put in chest (mined items)
turtle.suckDown() -- pull from lower chest (fuel)
end
eat()
GoToLocation(lastActionPositionx,lastActionPositiony,lastActionPositionz)
Turn(lastActionFacing)
end
end
function eat()
debugInfo("eating", 2)
currentMissionString = "Needing Nom Noms"
menu()
local i = 1
while i < 17 do
turtle.select(i)
turtle.suckDown()
if turtle.refuel(1) == true then
turtle.refuel() i = 17 -- only take 1 stack (decreases trips to drop off mined materials)
elseif i == 16 and turtle.getFuelLevel() < minimumFuelLevel then
feedMe()
end
i = i + 1
sleep(0.5)
end
turtle.select(1)
end
function feedMe()
debugInfo("waiting for feed" ,2)
currentMissionString = "Waiting for nom noms"
local event, param1 = os.pullEvent ("char")
eat()
end
function Turn(direction)
debugInfo("turning to "..tostring(direction), 1)
if direction == 0 then
if currentFacing == 1 then
debugInfo("turning left 1 ", 1)
TurnLeft(1)
elseif
currentFacing == 2 then
debugInfo("turning 180", 1)
TurnRight(2)
elseif currentFacing == 3 then
debugInfo("turning right", 1)
TurnRight(1)
end
elseif direction == 1 then
if currentFacing == 2 then
TurnLeft(1)
elseif currentFacing == 3 then
TurnRight(2)
elseif currentFacing == 0 then
TurnRight(1)
end
elseif direction == 2 then
if currentFacing == 3 then
TurnLeft(1)
elseif currentFacing == 0 then
TurnRight(2)
elseif currentFacing == 1 then
TurnRight(1)
end
else -- direction 3
if currentFacing == 0 then
TurnLeft(1)
elseif currentFacing == 1 then
TurnRight(2)
elseif currentFacing == 2 then
TurnRight(1)
end
end
end
function TurnRight(times)
debugInfo("turning Right", 2)
-- turning right
for i=1,times do
turtle.turnRight()
currentFacing = currentFacing +1
if currentFacing == 4 then
currentFacing = 0
end
end
end
function TurnLeft(times)
-- turning left
debugInfo("Turning Left", 2)
for i=1,times do
turtle.turnLeft()
currentFacing = currentFacing -1
if currentFacing < 0 then
currentFacing = 3
end
end
end
function GoForward(times)
debugInfo("Going Forward", 2) -- move some
for i=1,times do
if turtle.detect() then
turtle.dig()
end
turtle.forward()
end
end
function GoDown(times)
debugInfo("Getting Down", 2)
for i=1,times do
if turtle.detectDown() then
turtle.digDown()
end
turtle.down()
end
end
function GoUp(times)
debugInfo("Getting High", 2)
for i=1,times do
if turtle.detectUp() then
turtle.digUp()
end
turtle.up()
end
end
function GetFace()
debugInfo("Is that north", 2)
local oldx,oldy,oldz = GetPos()
GoForward(1)
GetPos()
if cx > oldx then
-- west
currentFacing = 3
elseif cx < oldx then
-- east
currentFacing = 1
elseif cz > oldz then
-- south
currentFacing = 0
else
-- north
currentFacing = 2
end
debugInfo("Facing "..tostring(currentFacing), 1)
end
function setLastActionPosition()
lastActionPositionx, lastActionPositiony, lastActionPositionz = GetPos()
lastActionFacing = currentFacing
end
function AtHome()
debugInfo("am I home?", 2)
GetPos()
if cx == coords[1][1]["var"] then
if cy == coords[1][2]["var"] then
if cz == coords[1][3]["var"] then
return true
else
return false
end
else
return false
end
else
return false
end
end
function GetPos()
debugInfo("Where am I?", 2)
cx,cy,cz = gps.locate(gpsTimeToWait,debugModeGPS)
if(cx == nil) then
rednet.open("right")
cx,cy,cz = gps.locate(gpsTimeToWait,debugModeGPS)
end
locx, locy, locz = gps.locate(gpsTimeToWait,debugModeGPS)
debugInfo(tostring(locx).." "..tostring(locy).." "..tostring(locz), 1)
return gps.locate(gpsTimeToWait,debugModeGPS)
end
function GoToLocation(x,y,z)
debugInfo("going to"..tostring(x).."x "..tostring(y).."y "..tostring(z).."z", 1)
while cx ~= x or cy ~= y or cz ~= z do
GetPos()
if cx < x then
-- east of it so go east
Turn(3)
GoForward(math.abs(cx-x))
elseif cx > x then
-- west of it so go east
Turn(1)
GoForward(math.abs(cx-x))
end
if cy < y then
-- under it
GoUp(math.abs(cy-y))
elseif cy > y then
-- over it
GoDown(math.abs(cy-y))
end
if cz > z then
-- south of it so go north
Turn(2)
GoForward(math.abs(cz-z))
elseif cz < z then
-- north of it so go south
Turn(0)
GoForward(math.abs(cz-z))
end
sleep(0.5)
end
end
function atLastActionPosition()
debugInfo("setting last action", 2)
GetPos()
if cx == lastActionPositionx then
if cy == lastActionPositiony then
if cz == lastActionPositionz then
if lastActionFacing ~= currentFacing then
Turn(lastActionFacing)
end
return true
else
return false
end
else
return false
end
else
return false
end
-- checkFuel()
end
function clearStripUp()
debugInfo("Mining Up", 2)
local atTop = false
local currentGap = 0
GetPos()
while atTop == false do
if coords[3][2]["var"] > cy then --
if turtle.detectUp() or turtle.detect() then
turtle.digUp()
turtle.dig()
GoUp(1)
cy = cy + 1 -- reduce rednetpings
else
turtle.dig()
currentGap = currentGap + 1
if currentGap == topGap then
currentGap = 0
atTop = true
goingUp = false
end
GoUp(1)
cy = cy + 1 -- reduce rednetpings
end
checkFuel()
else
atTop = true
goingUp = false
end
setLastActionPosition()
sleep(0.5)
end
atEndCheck()
end
function clearStripDown()
debugInfo("Mining Down", 2)
GetPos()
while cy > coords[2][2]["var"] do
if turtle.detectDown() or turtle.detect() then
turtle.digDown()
turtle.dig()
GoDown(1)
cy = cy - 1 -- reduce rednetpings
else
turtle.dig()
GoDown(1)
cy = cy - 1 -- reduce rednetpings
end
checkFuel()
sleep(0.5)
end
atEndCheck()
setLastActionPosition()
goingUp = true
end
function menu()
debugInfo("Show Menu", 2)
local hr = "#=====================================#"
local writeLine = 1
local targetLine = 1
term.clear() -- clear screen
term.setCursorPos(1, 1) -- reset cursor
writeALine(hr)
writeALine("# Welcome to d_four's Mountian Mover #")
writeALine(hr)
writeALine("# Location: X Y Z #")
writeALine("# Drop off:"..setSizeString(coords[1][1]["var"],6).." "..setSizeString(coords[1][2]["var"],6).." "..setSizeString(coords[1][3]["var"],6).." #")
writeALine("# Target Start:"..setSizeString(coords[2][1]["var"],6).." "..setSizeString(coords[2][2]["var"],6).." "..setSizeString(coords[2][3]["var"],6).." #")
writeALine("# Target End:"..setSizeString(coords[3][1]["var"],6).." "..setSizeString(coords[3][2]["var"],6).." "..setSizeString(coords[3][3]["var"],6).." #")
--writeALine("# #")
writeALine("# Amount of Fuel: "..setSizeString(turtle.getFuelLevel(),9).." #")
--writeALine("# #")
writeALine("#Current Mission:"..setSizeString(currentMissionString, 21).."#")
if isSetup == true then
writeALine("# press y to complete setup #")
else
writeALine("# #")
end writeALine(hr)
debugInfo(currentMissionString, 2)
term.setCursorPos(1, 12) -- set cursor to visible area
end
function setSizeString(string,size)
string = tostring(string)
while string.len(string) < size do
string = " "..string
end
return string
end
function writeALine(string)
local x,y = term.getCursorPos()
term.write(string) -- x right : y down
term.setCursorPos(x,y+1)
end
function setup()
debugInfo("Doing Setup", 2)
local crow = 1
local ccol = 1
while isSetup == true do
menu()
term.setCursorBlink(true)
term.setCursorPos(coords[crow][ccol]["x"],coords[crow][ccol]["y"])
local event, key = os.pullEvent("key")
if keys[key] == "Left" or keys[key] == "Up" or keys[key] == "Down" or keys[key] == "Right" then
if keys[key] == "Left" then
if ccol > 1 then
ccol = ccol - 1
end
end
if keys[key] == "Right" then
if ccol < 3 then
ccol = ccol + 1
end
end
if keys[key] == "Up" then
if crow > 1 then
crow = crow - 1
end
end
if keys[key] == "Down" then
if crow < 3 then
crow = crow + 1
end
end
elseif key == 14 or key == 211 then
-- delete key pressed
if(string.len(tostring(coords[crow][ccol]["var"]))) > 1 then
coords[crow][ccol]["var"] = tonumber( string.sub(coords[crow][ccol]["var"] ,0 ,string.len(coords[crow][ccol]["var"])-1 ))
else
coords[crow][ccol]["var"] = 0
end
elseif key == 12 then
-- minus key pressed
coords[crow][ccol]["var"] = coords[crow][ccol]["var"] - coords[crow][ccol]["var"] - coords[crow][ccol]["var"]
elseif key == 21 then
-- y key pressed setup finished
isSetup = false
lastActionPositionx = coords[2][1]["var"]
lastActionPositiony = coords[2][2]["var"]
lastActionPositionz = coords[2][3]["var"]
lastActionFacing = faceDirectionOfNextAction()
elseif key == 16 then
-- q key pressed quit time
term.clear()
term.setCursorPos(1,1)
print("Good Bye!")
isSetup = false
running = false
else
if(keys[key] ~= nil) and keys[key] ~= "Enter" then
if(string.len(coords[crow][ccol]["var"]) < 5) then
-- not menu move key so add values to current positions value
coords[crow][ccol]["var"] = tonumber(coords[crow][ccol]["var"] .. keys[key])
elseif debugLevel > 2 then
print(key)
end
end
end
sleep(0.5)
end
end
function quit()
debugInfo("Quitting", 3)
local event, key = os.pullEvent("key")
if key == 16 then
term.clear()
term.setCursorPos(1,1)
print("Good Bye!")
running = false
end
end
function moveToLastActioArea()
debugInfo("Going to last action space", 2) -- move to target start or last action position
if(lastActionPositionx == 0) and (lastActionPositiony == 0) and (lastActionPositionz == 0) then
-- start at beginning
setLastActionPosition()
currentMissionString = "Going to Start "
menu()
GoToLocation(coords[1][1]["var"],coords[1][2]["var"],coords[1][3]["var"])
goingUp = true
else
-- go to last action area
currentMissionString = "Resuming Position "
menu()
GoToLocation(lastActionPositionx,lastActionPositiony,lastActionPositionz)
overrideNextActionFace = true --[[BLOCK COMMENT KEEP AN EYE ON THIS MAY NOT BE NEEDED]]--
end
end
function faceDirectionOfNextAction()
debugInfo("Facing last direction", 2) -- if last acion face is set face that way and return
if overrideNextActionFace == true then
overrideNextActionFace = false
Turn(lastActionFacing)
return lastActionFacing
end -- face direction of actions: at start or end of line
if coords[3][1]["var"] >= coords[2][1]["var"] then
debugInfo("Will now Face West", 1)
Turn(3) -- face west and dig
return 3
elseif coords[3][1]["var"] <= coords[2][1]["var"] then
debugInfo("Will now Face East", 1)
Turn(1) -- face east and dig
return 1
elseif coords[3][3]["var"] >= coords[2][3]["var"] then
debugInfo("Will now Face South", 1)
Turn(0) -- face south and dig
return 0
elseif coords[3][3]["var"] <= coords[2][3]["var"] then
debugInfo("Will now Face North", 1)
Turn(2) -- face north and dig
return 0
else
debugInfo("I got lost", 2)
end
end
function doMining()
debugInfo("Time to mine", 2) -- if up go up till spaces = 5 or upper limit reached else down till y = lower limit
local inventoryCheck = amountOfStripsBeforeFullInvCheck
while notAtEnd == true do
if goingUp == true then
-- continue mining up
currentMissionString = "Mining Up "
menu()
clearStripUp()
savePointRecord("mining")
inventoryCheck = inventoryCheck - 1
else
-- continue mining down
currentMissionString = "Mining Down "
menu()
clearStripDown()
savePointRecord("mining")
inventoryCheck = inventoryCheck - 1
end
if inventoryCheck < 1 then
inventoryCheck = amountOfStripsBeforeFullInvCheck
if spacesInInventory() == false then
forceCheck = true
end
end
chooseNewDirection()
sleep(0.5)
end
-- got to end
GoToLocation(coords[1][1]["var"],coords[1][2]["var"],coords[1][3]["var"])
end
function spacesInInventory()
totalSpaces = 0
for i=1 , 16 do
if turtle.getItemSpace(i) == 64 then
totalSpaces = totalSpaces + 1
end
end
if totalSpaces > 1 then
return true
end
return false
end
function chooseNewDirection()
debugInfo("Chosing next direction", 2)
GetPos()
if currentFacing == 3 then---------------------------- Facing east
if coords[3][1]["var"] <= cx then -- at end
-- reached the end of row
-- turn into new next strip
if coords[3][3]["var"] > cz then -- end location is south
Turn(0)
GoForward(1)
Turn(1)
else ------------------------------ end location is north
Turn(2)
GoForward(1)
Turn(1)
end
else ------------------------------ end is east
if coords[3][1]["var"] == (cx +1) then -- is end 1 more meter east?
GoForward(1)
else
GoForward(2)
end
end
elseif currentFacing == 1 then------------------------- Facing West
if coords[2][1]["var"] >= cx then
-- reached the end of row
if coords[3][3]["var"] > cz then
Turn(0)
GoForward(1)
Turn(3)
else
Turn(2)
GoForward(1)
Turn(3)
end
else
-- add condition to go one forward when it equals end
if coords[3][1]["var"] == (cx -1) then
GoForward(1)
else
GoForward(2)
end
end
elseif currentFacing == 0 then ----------------------- Facing south
if coords[3][3]["var"] <= cz then
-- reached the end of row
if coords[3][1]["var"] > cx then
Turn(3)
GoForward(1)
Turn(0)
else
Turn(3)
GoForward(1)
Turn(2)
end
else
-- add condition to go one forward when it equals end
if coords[3][3]["var"] == (cz +1) then
GoForward(1)
else
GoForward(2)
end
end
else -------------------------------------------------- Facing north
if coords[2][3]["var"] >= cz then
-- reached the end of row
if coords[3][1]["var"] > cx then
Turn(3)
GoForward(1)
Turn(2)
else
Turn(3)
GoForward(1)
Turn(0)
end
else
-- add condition to go one forward when it equals end
if coords[3][3]["var"] == (cz -1) then
GoForward(1)
else
GoForward(2)
end
end
end
end
function getDistanceTofuel()
debugInfo("How Far to nom noms", 3)
GetPos()
local xDistance = math.abs(cx - coords[1][1]["var"])
local yDistance = math.abs(cy - coords[1][2]["var"])
local zDistance = math.abs(cz - coords[1][3]["var"])
local distance = xDistance+yDistance+zDistance
debugInfo(tostring(distance), 1)
return distance
end
function serealize(table, name, saveString)
if type(name) == "string" then
saveString = saveString..name.." = {" -- opens table
else
-- table has no name [will stick with index ints]
saveString = saveString.."{"
end -- loop through each table entry
first = true
for key1,val1 in pairs( table ) do
if first == true then
first = false
else
saveString = saveString..","
end
-- check if table has tables in
if type (val1) == "table" then
saveString = serealize(val1,key1,saveString) -- go back through serializer
elseif type (key1) == "string" then
saveString = saveString.."[\""..tostring(key1).."\"] = "..tostring(val1)..""
else
-- not a table
saveString = saveString..tostring(val1)..""
end
end
saveString = saveString.."}" -- closes table
return saveString
end
function unserealize(string)
makeVar = loadstring(string.."; return coords") -- create function from string
coords = makeVar() -- execute string
end
function savePointRecord(curretJob)
debugInfo("Saving", 2)
local savefile
savefile = fs.open( statusFile , "w")
savefile.writeLine(curretJob)
savefile.writeLine(serealize(coords,"coords", "")) -- serialise table into a string for saving
savefile.writeLine("lastActionPositionx:"..tostring(lastActionPositionx))
savefile.writeLine("lastActionPositiony:"..tostring(lastActionPositiony))
savefile.writeLine("lastActionPositionz:"..tostring(lastActionPositionz))
savefile.writeLine("lastActionFacing:"..tostring(lastActionFacing))
savefile.writeLine("goingUp:"..tostring(goingUp))
savefile.close()
end
function savePointLoad()
debugInfo("Loading", 2)
if fs.exists(statusFile) then
local savefile = fs.open(statusFile , "r") -- open file to read
local firstString = savefile.readLine()
if firstString ~= "atSetup" then
unserealize(savefile.readLine())
lastActionPositionx = tonumber(splitString(savefile.readLine(),':'))
lastActionPositiony = tonumber(splitString(savefile.readLine(),':'))
lastActionPositionz = tonumber(splitString(savefile.readLine(),':'))
lastActionFacing = tonumber(splitString(savefile.readLine(),':'))
if savefile.readLine() == "goingUp:true" then
goingUp = false -- revert to previous save
else
goingUp = true
end
skipSetup = true
overrideNextActionFace = true
end
savefile.close()
end
end
function splitString(string,delimiter)
returnString = string.sub(string , string.find(string ,delimiter)+1, -1)
return returnString
end
function debugInfo(string, level)
if level <= debugLevel then
if debugMode == true then
if debugWriteToFile then
debugfile = fs.open("debuglog", "a")
debugfile.writeLine(string)
debugfile.close()
end
rednet.broadcast(string)
end
end
end
function checkLoad()
if fs.exists(statusFile) or fs.exists(statusFile2) then
print("Save File Located: Do you want to load this file? y/n")
local choiceMade = false
while choiceMade == false do
local event, char = os.pullEvent("char")
if char == "y" then
savePointLoad() -- load up save data if save data does not contain atSetup
choiceMade = true
elseif char == "n" then
lastActionPositionx = 0
lastActionPositiony = 0
lastActionPositionz = 0
lastActionFacing = 0
goingUp = true
overrideNextActionFace = false
setup()
savePointRecord("atSetup") -- overwrie both
savePointRecord("atSetup")
choiceMade = true
end
end
end
end
function atEndCheck()
GetPos()
if ((math.abs(coords[2][1]["var"] - coords[3][1]["var"])) % 2) == 0 then
-- even number of rows so end at start x loc and end z loc
if cx == coords[2][1]["var"] and cz == coords[3][3]["var"] then
notAtEnd = false
running = false
end
else
-- odd number of rows so end and end x and end z
if cx == coords[3][1]["var"] and cz == coords[3][3]["var"] then
notAtEnd = false
running = false
end
end
end
-- MAIN LOOP ---------------------------------------
checkLoad()
running = true
while running == true do
debugInfo("Running Prog", 3)
if running == true then
currentMissionString = "Getting Location "
GetFace() -- get current facing N,E,S,W, and location
menu()
while atLastActionPosition() == false do
moveToLastActioArea()
sleep(0.5)
end
faceDirectionOfNextAction()
doMining()
debugInfo("Time for quick Snooze", 3)
sleep(0.5)
end
end
print("Mission Complete")