Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- ]]
- --VARIABLES
- local line --line inside file
- local stringQuestionAsked --Question for the Menu
- local x,y = term.getSize() --Size of the screen
- local highlighted = 1 --Chosen Element inside menu
- local choices = {} --Table of choices inside menu
- local chosenOne --Chosen element of the menu
- local removed = 0 --Variable to remove the right element from list
- local success, data --Variables for inspection of Blocks
- local encodedString
- local i --Variable for Calculation
- local m --Variable for Calculation
- local n --Variable for Calculation
- --FILES
- --Names
- local turtleDataFile = "turtleDataFile" --Name of the File that saves 1: X coordinate, 2: Z coordinate, 3: Rotation, 4: Number of Holes
- local turtleModemFile = "turtleModemFile" --Name of the File that saves the side of the Wireless Modem
- local overseerIDFile = "overseerID" --Name of the File that saves the IDs of every Overseer
- local trashBlockFile = "trashBlock" --Name of the File that saves every Block that the Turtle shouldn't mine
- local trackingBlockFile = "trackingBlock" --Name of the File that saves the Blocks that are supposed to be tracked
- local turtleActivityFile = "turtleActivity" --Name of the File that saves the Blocks that are supposed to be tracked
- --Tables
- local turtleData = {} --Table to save the Data inside the turtleDataFile
- local turtleModem = {} --Table to save the Data inside the turtleModemFile
- local overseerID = {} --Table to save the Data inside the overseerIDFile
- local trashBlock = {} --Table to save the Data inside the trachBlockFile
- local newTrashBlock = {} --Table to save the new Data of Trash Blocks
- local trackingBlock = {} --Table to save the Data inside the trackingBlockFile
- local newTrackingBlock = {} --Table to save the Data inside the trackingBlockFile
- local turtleActivity = {} --Table to save the Data inside the trackingBlockFile
- --FUNKTIONS
- function load(fileName,arrayName) --Loading data that is inside File
- file = fs.open("Data/"..fileName,"r") -- Open a file for reading.
- line = file.readLine() -- This function reads the next line in the file, until the end.
- repeat -- Start a loop which will read lines into a table until no lines are left.
- table.insert(arrayName,line) -- Puts the value of the current line into the table we have.
- line = file.readLine() -- read the next line
- until line == nil -- readLine() returns nil when the end of the file is reached.
- file.close() -- Close up the file ready for use again.
- end
- function createFile(File) --Function that is used for the sole purpose of creating a file without editing it
- local file = fs.open("Data/"..File,"a")
- file.close()
- end
- function resetScreen()
- term.clear()
- term.setCursorPos(1,1)
- end
- --MENU
- function writeChoices() --writes the choices down made for the menu
- for i=1,#choices do
- if i == highlighted then
- term.setCursorPos(((x/2)-(("<| "..choices[i].." |>"):len()/2)),i + 2)
- term.clearLine()
- term.write("<| "..choices[i].." |>")
- else
- term.setCursorPos(((x/2)-(choices[i]:len()/2)),i + 2)
- term.clearLine()
- term.write(choices[i])
- end
- end
- end
- function menuSelection() --waits for key input and changes the highlighted menuElemnt
- while true do
- writeChoices()
- local event, key = os.pullEvent( "key" )
- if key == keys.down then
- highlighted = highlighted + 1
- end
- if key == keys.up then
- highlighted = highlighted - 1
- end
- if key == keys.enter then
- chosenOne = choices[highlighted]
- break
- end
- if highlighted == 0 then
- highlighted = #choices
- end
- if highlighted == #choices + 1 then
- highlighted = 1
- end
- end
- end
- function Menu() --Creates a menu
- term.clear()
- term.setCursorPos(math.ceil((x/2)-(stringQuestionAsked:len()/2)),1)
- term.write(stringQuestionAsked)
- menuSelection()
- end
- function encodeMinerSend()
- turtleModem = {}
- load(turtleModemFile,turtleModem)
- rednet.open(turtleModem[1])
- turtleData = {}
- load(turtleDataFile,turtleData)
- table.insert(turtleData,turtle.getFuelLevel())
- trackingBlock = {}
- load(trackingBlockFile,trackingBlock)
- table.insert(turtleData,trackingBlock[1])
- table.insert(turtleData,trackingBlock[2])
- table.remove(turtleData,3)
- table.remove(turtleData,4)
- encodedString = "Miner%"
- for i=1,#turtleData,1 do
- encodedString = encodedString..turtleData[i].."%"
- end
- overseerID = {}
- load(overseerIDFile,overseerID)
- for i=1,#overseerID,1 do
- local x = tonumber(overseerID[i])
- rednet.send(x,encodedString)
- end
- end
- function refuel()
- while true do
- if turtle.getFuelLevel() < (turtle.getFuelLimit() - 100) and turtle.getItemCount(4) > 1 then
- turtle.select(4)
- turtle.refuel(1)
- else
- break
- end
- end
- turtle.select(1)
- end
- function space()
- local x = {}
- for i = 5,16,1 do
- if turtle.getItemCount(i) == 0 then
- table.insert(x,"i")
- end
- end
- if #x < 2 then
- turtle.select(2)
- if turtle.detect() == true then
- turtle.dig()
- end
- turtle.place()
- for i=5,16,1 do
- turtle.select(i)
- turtle.drop()
- end
- turtle.select(1)
- turtle.dig()
- end
- end
- function writeArrayFile(array,file)
- local file = fs.open("Data/"..file,"w")
- for i=1,#array,1 do
- file.writeLine(array[i])
- end
- file.close()
- end
- function changeDirectionL()
- turtleData = {}
- load(turtleDataFile,turtleData)
- turtle.turnLeft()
- if turtleData[3] == "1" then
- table.remove(turtleData,3)
- table.insert(turtleData,3,"4")
- writeArrayFile(turtleData,turtleDataFile)
- elseif turtleData[3] == "2" then
- table.remove(turtleData,3)
- table.insert(turtleData,3,"1")
- writeArrayFile(turtleData,turtleDataFile)
- elseif turtleData[3] == "3" then
- table.remove(turtleData,3)
- table.insert(turtleData,3,"2")
- writeArrayFile(turtleData,turtleDataFile)
- elseif turtleData[3] == "4" then
- table.remove(turtleData,3)
- table.insert(turtleData,3,"3")
- writeArrayFile(turtleData,turtleDataFile)
- end
- end
- function changeDirectionR()
- turtleData= {}
- load(turtleDataFile,turtleData)
- turtle.turnRight()
- if turtleData[3] == "1" then
- table.remove(turtleData,3)
- table.insert(turtleData,3,"2")
- writeArrayFile(turtleData,turtleDataFile)
- elseif turtleData[3] == "2" then
- table.remove(turtleData,3)
- table.insert(turtleData,3,"3")
- writeArrayFile(turtleData,turtleDataFile)
- elseif turtleData[3] == "3" then
- table.remove(turtleData,3)
- table.insert(turtleData,3,"4")
- writeArrayFile(turtleData,turtleDataFile)
- elseif turtleData[3] == "4" then
- table.remove(turtleData,3)
- table.insert(turtleData,3,"1")
- writeArrayFile(turtleData,turtleDataFile)
- end
- end
- function override(array,file,position,move) --Change one line of a file
- array = {}
- load(file,array)
- local x = array[tonumber(position)] + tonumber(move)
- table.remove(array,position)
- table.insert(array,position,x)
- local file = fs.open("Data/"..file,"w")
- for i=1,#array,1 do
- file.writeLine(array[i])
- end
- file.close()
- end
- function walking(facing)
- if facing == "1" then
- while true do
- if turtle.forward() == true then
- break
- elseif turtle.dig() == true then
- turtle.dig()
- end
- end
- override(turtleActivity,turtleActivityFile,"3","-1")
- override(turtleData,turtleDataFile,"2","-1")
- end
- if facing == "2" then
- while true do
- if turtle.forward() == true then
- break
- elseif turtle.dig() == true then
- turtle.dig()
- end
- end
- override(turtleActivity,turtleActivityFile,"2","1")
- override(turtleData,turtleDataFile,"1","1")
- end
- if facing == "3" then
- while true do
- if turtle.forward() == true then
- break
- elseif turtle.dig() == true then
- turtle.dig()
- end
- end
- override(turtleActivity,turtleActivityFile,"3","1")
- override(turtleData,turtleDataFile,"2","1")
- end
- if facing == "4" then
- while true do
- if turtle.forward() == true then
- break
- elseif turtle.dig() == true then
- turtle.dig()
- end
- end
- override(turtleActivity,turtleActivityFile,"2","-1")
- override(turtleData,turtleDataFile,"1","-1")
- end
- end
- function newH2()
- turtleActivity = {}
- load(turtleActivityFile,turtleActivity)
- turtleData = {}
- load(turtleDataFile,turtleData)
- turtleActivity = {}
- load(turtleActivityFile,turtleActivity)
- while true do
- turtleData = {}
- load(turtleDataFile,turtleData)
- turtleActivity = {}
- load(turtleActivityFile,turtleActivity)
- print(turtleActivity[2])
- if tostring(turtleActivity[2]) == "0.0" then
- break
- end
- if tostring(turtleActivity[2]) > "0" then
- turtleData = {}
- load(turtleDataFile,turtleData)
- while tostring(turtleData[3]) ~= "4" do
- changeDirectionR()
- turtleData = {}
- load(turtleDataFile,turtleData)
- end
- turtleData = {}
- load(turtleDataFile,turtleData)
- walking(turtleData[3])
- end
- if tostring(turtleActivity[2]) < "0" then
- while tostring(turtleData[3]) ~= "2" do
- changeDirectionR()
- turtleData = {}
- load(turtleDataFile,turtleData)
- end
- turtleData = {}
- load(turtleDataFile,turtleData)
- walking(turtleData[3])
- end
- end
- while true do
- turtleData = {}
- load(turtleDataFile,turtleData)
- turtleActivity = {}
- load(turtleActivityFile,turtleActivity)
- print(turtleActivity[2])
- if tostring(turtleActivity[3]) == "0.0" then
- turtleData = {}
- load(turtleDataFile,turtleData)
- while tostring(turtleData[3]) ~= turtleData[5] do
- changeDirectionR()
- turtleData = {}
- load(turtleDataFile,turtleData)
- end
- break
- end
- if tostring(turtleActivity[3]) > "0" then
- turtleData = {}
- load(turtleDataFile,turtleData)
- while tostring(turtleData[3]) ~= "1" do
- changeDirectionR()
- turtleData = {}
- load(turtleDataFile,turtleData)
- end
- turtleData = {}
- load(turtleDataFile,turtleData)
- walking(turtleData[3])
- end
- if tostring(turtleActivity[3]) < "0" then
- while tostring(turtleData[3]) ~= "3" do
- changeDirectionR()
- turtleData = {}
- load(turtleDataFile,turtleData)
- end
- turtleData = {}
- load(turtleDataFile,turtleData)
- walking(turtleData[3])
- end
- end
- end
- --CODE
- --VOID START
- fs.makeDir("Data")
- createFile(turtleDataFile)
- createFile(turtleModemFile)
- createFile(overseerIDFile)
- createFile(trashBlockFile)
- createFile(trackingBlockFile)
- createFile(turtleActivityFile)
- load(turtleDataFile,turtleData)
- load(turtleModemFile,turtleModem)
- load(overseerIDFile,overseerID)
- load(trashBlockFile,trashBlock)
- load(trackingBlockFile,trackingBlock)
- load(turtleActivityFile,turtleActivity)
- --FIRST TIME SETUP
- --TURTLE DATA
- turtleData = {}
- load(turtleDataFile,turtleData)
- if turtleData[1] == nil then --TurtleData first time installation
- while true do --Turtles X Coordinate
- resetScreen()
- term.write("What is the turtles X Coordinate?")
- term.setCursorPos(1,2)
- term.write("X: ")
- local x = read()
- highlighted = 1
- stringQuestionAsked = "Is the X Coordinate really: "..x.."?"
- choices ={"Yes it is","No it's not"}
- Menu()
- if choices[1] == chosenOne then
- table.insert(turtleData,1,x)
- break
- end
- end
- while true do --Turtles Z Coordinate
- resetScreen()
- term.write("What is the turtles Z Coordinate?")
- term.setCursorPos(1,2)
- term.write("Z: ")
- local x = read()
- stringQuestionAsked = "Is the Z Coordinate really: "..x.."?"
- highlighted = 1
- Menu()
- if choices[1] == chosenOne then
- table.insert(turtleData,2,x)
- break
- end
- end
- while true do --Turtles Rotation
- resetScreen()
- stringQuestionAsked = "Which way is the turtle Facing?"
- choices = {"North","East","South","West"}
- highlighted = 1
- Menu()
- local x = chosenOne
- stringQuestionAsked = "You sure the turtle is facing "..x.."?"
- choices = {"Yes I am","No I'm not"}
- highlighted = 1
- Menu()
- if choices[1] == chosenOne then
- if x == "North" then
- x = "1"
- elseif x == "East" then
- x = "2"
- elseif x == "South" then
- x = "3"
- elseif x == "West" then
- x = "4"
- end
- table.insert(turtleData,3,x)
- break
- end
- end
- table.insert(turtleData,4,"0") --Turtle Holes
- table.insert(turtleData,5,turtleData[3])
- local file = fs.open("Data/"..turtleDataFile,"a")
- for i=1, #turtleData, 1 do
- file.writeLine(turtleData[i])
- end
- file.close()
- end
- --TURTLE WIRELESS MODEM SIDE
- turtleModem = {}
- load(turtleModemFile,turtleModem)
- if turtleModem[1] == nil then
- resetScreen()
- print("On which side is the Wireless Modem of the turtle from the turtles Perspective?")
- os.sleep(8)
- stringQuestionAsked = "Where is the Wireless Modem"
- choices = {"left","right"}
- Menu()
- local file = fs.open("Data/"..turtleModemFile,"a")
- file.writeLine(chosenOne)
- file.close()
- end
- --OVERSEER IDS
- overseerID = {}
- load(overseerIDFile,overseerID)
- if overseerID[1] == nil then
- while true do
- resetScreen()
- term.write("What is the overseer's ID?")
- term.setCursorPos(1,2)
- term.write("Command: os.getComputerID()")
- term.setCursorPos(1,3)
- term.write("ID: ")
- local x = read()
- stringQuestionAsked = "Are you sure this is the ID "..x.."?"
- choices = {"Yes I am","No I'm not"}
- highlighted = 1
- Menu()
- if choices[1] == chosenOne then
- local add = true
- load(overseerIDFile,overseerID)
- for i=1, #overseerID, 1 do
- if x == overseerID[i] then
- add = false
- end
- end
- if add == true then
- local file = fs.open("Data/"..overseerIDFile,"a")
- file.writeLine(x)
- file.close()
- else
- resetScreen()
- term.write("That Overseer has already been added")
- os.sleep(1)
- end
- stringQuestionAsked = "Do you want to add another overseer?"
- choices = {"Yes I do","No I don't"}
- highlighted = 1
- Menu()
- if choices[2] == chosenOne then
- break
- end
- end
- end
- end
- --TRASHBLOCKS
- trashBlock = {}
- load(trashBlockFile,trashBlock)
- if trashBlock[1] == nil then
- while true do
- stringQuestionAsked = "Add a new Block to ignore"
- choices = {"Type in Code","Place block in front","Banned Blocks","Quit","Tutorial [start]"}
- highlighted = 1
- Menu()
- if choices[1] == chosenOne then --Type in Code
- while true do
- resetScreen()
- print("Type in the code of the Block")
- print("for example minecraft:stone")
- term.write("Code: ")
- local x = read()
- stringQuestionAsked = "Is "..x.." correct?"
- choices = {"Yes it is", "No it isn't"}
- highlighted = 1
- Menu()
- if choices[1] == chosenOne then
- local add = true
- trashBlock = {}
- load(trashBlockFile,trashBlock)
- for i = 1,#trashBlock,1 do
- if trashBlock[i] == x then
- add = false
- end
- end
- if add == true then
- local file = fs.open("Data/"..trashBlockFile,"a")
- file.writeLine(x)
- file.close()
- resetScreen()
- print(x.." won't get mined any more.")
- os.sleep(2)
- else
- resetScreen()
- term.write("That Block has already been added")
- os.sleep(2)
- end
- break
- end
- end
- elseif choices[2] == chosenOne then --Place a Block in front of turtle
- while true do
- success, data = turtle.inspect()
- if data.name == nil then
- resetScreen()
- print("You have to place a Block in front of the turtle before starting this function!")
- os.sleep(3)
- break
- end
- stringQuestionAsked = "Is "..data.name.." correct?"
- choices = {"Yes it is", "No it isn't"}
- highlighted = 1
- Menu()
- if choices[1] == chosenOne then
- local add = true
- trashBlock = {}
- load(trashBlockFile,trashBlock)
- for i = 1,#trashBlock,1 do
- if trashBlock[i] == data.name then
- add = false
- end
- end
- if add == true then
- local file = fs.open("Data/"..trashBlockFile,"a")
- file.writeLine(data.name)
- file.close()
- resetScreen()
- print(data.name.." won't get mined any more.")
- os.sleep(2)
- break
- else
- resetScreen()
- term.write("That Block has already been added")
- os.sleep(2)
- break
- end
- end
- end
- elseif choices[3] == chosenOne then --Remove Block from List
- removed = 0
- trashBlock = {}
- newTrashBlock = {}
- load(trashBlockFile,trashBlock)
- for m=1,#trashBlock,1 do
- table.insert(newTrashBlock,m,trashBlock[m])
- end
- for i=1,#trashBlock do
- stringQuestionAsked = "Remove "..trashBlock[i].."?"
- choices = {"Yes I will","No I won't"}
- highlighted = 2
- Menu()
- if choices[1] == chosenOne then
- table.remove(newTrashBlock,i-removed)
- removed = removed + 1
- end
- end
- trashBlock = newTrashBlock
- local file = fs.open("Data/"..trashBlockFile,"w")
- for n=1,#trashBlock,1 do
- file.writeLine(trashBlock[n])
- end
- file.close()
- elseif choices[4] == chosenOne then --Quit
- trashBlock = {}
- load(trashBlockFile,trashBlock)
- if trashBlock[1] == nil then
- local file = fs.open("Data/"..trashBlockFile,"a")
- file.writeLine(1)
- file.close()
- end
- break
- elseif choices[5] == chosenOne then --Tutorial
- while true do
- stringQuestionAsked = "Tutorial"
- choices = {"Type in Code","Place block in front","Banned Blocks","Quit","Tutorial [stop]"}
- highlighted = 1
- Menu()
- if choices[1] == chosenOne then
- resetScreen()
- print("Type in Code:")
- print("You will be able to type in a code id for any block in the game that the turtle is not supposed to mine. You will have to know the Code though. For example minecraft:stone for stone.")
- os.sleep(8)
- elseif choices[2] == chosenOne then
- resetScreen()
- print("Place block in front:")
- print("First Place the Block you want to add in front of the Turtle then Select this Button. This will add that Block to the list of Blocks that it won't mine")
- os.sleep(4)
- elseif choices[3] == chosenOne then
- resetScreen()
- print("Let's you remove previously added Blocks")
- os.sleep(2)
- elseif choices[4] == chosenOne then
- resetScreen()
- print("Quit:")
- term.write("Quits the Add new Block Menu")
- os.sleep(3)
- elseif choices[5] == chosenOne then
- print("Banned Blocks:")
- print("Displays a list of all of the Blocks that have been banned by the system")
- os.sleep(3)
- elseif choices[5] == chosenOne then
- break
- end
- end
- end
- end
- end
- --TRACKING BLOCKS
- trackingBlock = {}
- load(trackingBlockFile,trackingBlock)
- if trackingBlock[1] == nil then
- while true do
- stringQuestionAsked = "Add a new Block to track"
- choices = {"Type in Code","Place block in front","Tracked Blocks","Quit"}
- highlighted = 1
- Menu()
- if choices[1] == chosenOne then --Type in Code
- while true do
- trackingBlock = {}
- load(trackingBlockFile,trackingBlock)
- if trackingBlock[1] ~= nil then
- resetScreen()
- term.write("You can only Track one Block")
- os.sleep(5)
- break
- end
- resetScreen()
- print("Type in the code of the Block")
- print("for example minecraft:diamond_ore")
- term.write("Code: ")
- local x = read()
- stringQuestionAsked = "Is "..x.." correct?"
- choices = {"Yes it is", "No it isn't"}
- highlighted = 1
- Menu()
- if choices[1] == chosenOne then
- local add = true
- trackingBlock = {}
- load(trackingBlockFile,trackingBlock)
- for i = 1,#trackingBlock,1 do
- if trackingBlock[i] == x then
- add = false
- end
- end
- if add == true then
- local file = fs.open("Data/"..trackingBlockFile,"a")
- file.writeLine(x)
- file.close()
- resetScreen()
- print(x.." will be tracked")
- os.sleep(2)
- else
- resetScreen()
- term.write("That Block has already been added")
- os.sleep(2)
- end
- break
- end
- end
- elseif choices[2] == chosenOne then --Place a Block in front of turtle
- while true do
- trackingBlock = {}
- load(trackingBlockFile,trackingBlock)
- if trackingBlock[1] ~= nil then
- resetScreen()
- term.write("You can only Track one Block")
- os.sleep(5)
- break
- end
- success, data = turtle.inspect()
- if data.name == nil then
- resetScreen()
- print("You have to place a Block in front of the turtle before starting this function!")
- os.sleep(3)
- break
- end
- stringQuestionAsked = "Is "..data.name.." correct?"
- choices = {"Yes it is", "No it isn't"}
- highlighted = 1
- Menu()
- if choices[1] == chosenOne then
- local add = true
- trackingBlock = {}
- load(trackingBlockFile,trackingBlock)
- for i = 1,#trackingBlock,1 do
- if trackingBlock[i] == data.name then
- add = false
- end
- end
- if add == true then
- local file = fs.open("Data/"..trackingBlockFile,"a")
- file.writeLine(data.name)
- file.close()
- resetScreen()
- print(data.name.." will be tracked.")
- os.sleep(2)
- break
- else
- resetScreen()
- term.write("That Block has already been added")
- os.sleep(2)
- break
- end
- end
- end
- elseif choices[3] == chosenOne then --Remove Block from List
- removed = 0
- trackingBlock = {}
- newTrackingBlock = {}
- load(trackingBlockFile,trackingBlock)
- for m=1,#trackingBlock,1 do
- table.insert(newTrackingBlock,m,trackingBlock[m])
- end
- for i=1,#trackingBlock do
- stringQuestionAsked = "Remove "..trackingBlock[i].."?"
- choices = {"Yes I will","No I won't"}
- highlighted = 2
- Menu()
- if choices[1] == chosenOne then
- table.remove(newTrackingBlock,i-removed)
- removed = removed + 1
- end
- end
- trackingBlock = newTrackingBlock
- local file = fs.open("Data/"..trackingBlockFile,"w")
- for n=1,#trackingBlock,1 do
- file.writeLine(trackingBlock[n])
- end
- file.close()
- elseif choices[4] == chosenOne then --Quit
- trackingBlock = {}
- load(trackingBlockFile,trackingBlock)
- if trackingBlock[1] == nil then
- local file = fs.open("Data/"..trackingBlockFile,"a")
- file.writeLine(1)
- file.close()
- end
- break
- end
- end
- end
- trackingBlock = {}
- load(trackingBlockFile,trackingBlock)
- if trackingBlock[2] == nil then
- local file = fs.open("Data/"..trackingBlockFile,"a")
- file.writeLine("0")
- file.close()
- end
- turtleActivity = {}
- load(turtleActivityFile,turtleActivity)
- if turtleActivity[1] == nil then
- local file = fs.open("Data/"..turtleActivityFile,"a")
- file.writeLine("start")
- file.close()
- end
- --CODE
- while true do
- encodeMinerSend()
- turtleActivity = {}
- load(turtleActivityFile,turtleActivity)
- if turtleActivity[1] == "start" then
- if turtle.detectUp() == true then
- turtle.digUp()
- end
- turtle.select(1)
- turtle.placeUp()
- refuel()
- space()
- local file = fs.open("Data/"..turtleActivityFile,"w")
- file.writeLine("digD")
- file.close()
- end
- turtleActivity = {}
- load(turtleActivityFile,turtleActivity)
- if turtleActivity[1] == "digD" then
- while true do
- success, data = turtle.inspectDown()
- if data.name == "minecraft:bedrock" then
- local file = fs.open("Data/"..turtleActivityFile,"w")
- file.writeLine("digU")
- file.close()
- break
- end
- load(trackingBlockFile,trackingBlock)
- if data.name == trackingBlock[1] then
- local x = tonumber(trackingBlock[2]) + 1
- local file = fs.open("Data/"..trackingBlockFile,"w")
- file.writeLine(trackingBlock[1])
- file.writeLine(tostring(x))
- file.close()
- encodeMinerSend()
- end
- turtle.digDown()
- turtle.down()
- space()
- refuel()
- encodeMinerSend()
- end
- end
- turtleActivity = {}
- load(turtleActivityFile,turtleActivity)
- if turtleActivity[1] == "digU" then
- while true do
- trackingBlock = {}
- load(trackingBlockFile,trackingBlock)
- trashBlock = {}
- load(trashBlockFile,trashBlock)
- success, data = turtle.inspectUp()
- if data.name == "ChickenChunks:chickenChunkLoader" then
- local file = fs.open("Data/"..turtleActivityFile,"w")
- file.writeLine("newH1")
- file.close()
- if turtle.getItemCount(3) > 1 then
- turtle.select(3)
- turtle.placeDown()
- turtle.select(1)
- end
- turtleData = {}
- load(turtleDataFile,turtleData)
- while tostring(turtleData[3]) ~= turtleData[5] do
- changeDirectionL()
- turtleData = {}
- load(turtleDataFile,turtleData)
- end
- turtleData = {}
- load(turtleDataFile,turtleData)
- override(turtleData,turtleDataFile,4,1)
- break
- end
- for i=1,4,1 do
- local mine = "true"
- success, data = turtle.inspect()
- if data.name == trackingBlock[1] then
- local x = tonumber(trackingBlock[2]) + 1
- local file = fs.open("Data/"..trackingBlockFile,"w")
- file.writeLine(trackingBlock[1])
- file.writeLine(tostring(x))
- file.close()
- encodeMinerSend()
- mine = "true"
- end
- for n=1,#trashBlock,1 do
- success, data = turtle.inspect()
- if data.name == trashBlock[n] then
- mine = "false"
- end
- end
- if mine == "true" then
- turtle.dig()
- space()
- end
- turtle.turnLeft()
- end
- turtle.up()
- refuel()
- end
- end
- turtleActivity = {}
- load(turtleActivityFile,turtleActivity)
- if turtleActivity[1] == "newH1" and turtleActivity[2] == nil then
- local file = fs.open("Data/"..turtleActivityFile,"a")
- file.writeLine(0) --X
- file.writeLine(0) --Z
- file.close()
- elseif turtleActivity[1] == "newH1" and turtleActivity[2] ~= nil then
- print("Hello")
- newH2()
- end
- turtleActivity = {}
- load(turtleActivityFile,turtleActivity)
- if turtleActivity[1] == "newH1" then
- turtleData = {}
- load(turtleDataFile,turtleData)
- walking(turtleData[3])
- encodeMinerSend()
- changeDirectionR()
- turtleData = {}
- load(turtleDataFile,turtleData)
- walking(turtleData[3])
- encodeMinerSend()
- turtleData = {}
- load(turtleDataFile,turtleData)
- walking(turtleData[3])
- encodeMinerSend()
- turtle.select(1)
- turtle.digUp()
- turtle.placeUp()
- changeDirectionL()
- turtleActivity = {}
- load(turtleActivityFile,turtleActivity)
- table.remove(turtleActivity,1)
- table.insert(turtleActivity,1,"newH2")
- local file = fs.open("Data/"..turtleActivityFile,"w")
- for i=1,#turtleActivity,1 do
- file.writeLine(turtleActivity[i])
- end
- file.close()
- end
- turtleActivity = {}
- load(turtleActivityFile,turtleActivity)
- if turtleActivity[1] == "newH2" then
- newH2()
- turtle.digUp()
- turtleActivity = {}
- load(turtleActivityFile,turtleActivity)
- table.remove(turtleActivity,1)
- table.insert(turtleActivity,1,"newH3")
- local file = fs.open("Data/"..turtleActivityFile,"w")
- file.writeLine(turtleActivity[1])
- file.close()
- end
- turtleActivity = {}
- load(turtleActivityFile,turtleActivity)
- if turtleActivity[1] == "newH3" and turtleActivity[3] == nil then
- local file = fs.open("Data/"..turtleActivityFile,"a")
- file.writeLine(0) --X
- file.writeLine(0) --Z
- file.close()
- elseif turtleActivity[1] == "newH3" and turtleActivity[3] ~= nil then
- newH2()
- end
- turtleActivity = {}
- load(turtleActivityFile,turtleActivity)
- if turtleActivity[1] == "newH3" then
- turtleData = {}
- load(turtleDataFile,turtleData)
- walking(turtleData[3])
- encodeMinerSend()
- changeDirectionR()
- turtleData = {}
- load(turtleDataFile,turtleData)
- walking(turtleData[3])
- encodeMinerSend()
- turtleData = {}
- load(turtleDataFile,turtleData)
- walking(turtleData[3])
- encodeMinerSend()
- turtleActivity = {}
- load(turtleActivityFile,turtleActivity)
- table.remove(turtleActivity,1)
- table.insert(turtleActivity,1,"digD")
- local file = fs.open("Data/"..turtleActivityFile,"w")
- file.writeLine(turtleActivity[1])
- file.close()
- end
- end
- --next Step send to overseer
- --then start digging first hole whilest updating stats and sending to overseer
- --then create more scripts to reset overseer ID's, Everything, trackingBlocks, trackedBlockes, trashBlocks
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement