Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- nglist = {}
- oklist = {}
- function init()
- if fs.exists("OK.lst") then
- local ngf = fs.open("OK.lst","r")
- local lname = ngf.readLine()
- while ngf ~= nil do
- nglist[#nglist+1] = lname
- end
- ngf.close()
- end
- if fs.exists("NG.lst") then
- local okf = fs.open("NG.lst","r")
- local lname = okf.readLine()
- while okf ~= nil do
- oklist[#oklist+1] = lname
- end
- okf.close()
- end
- end
- function addlist(fname,code)
- local af = fs.open(fname,"a")
- af.writeLine(code)
- af.close()
- end
- function checkNG(side)
- if side == nil then
- side = ""
- end
- local ok,data = turtle["inspect"..side]()
- if not ok then
- return false
- end
- local checkname = data["name"]
- for i, v in ipairs(nglist) do
- if v == checkname then
- return true
- end
- end
- return false
- end
- function checkOK(side)
- if side == nil then
- side = ""
- end
- local ok,data = turtle["inspect"..side]()
- if not ok then
- return false
- end
- local checkname = data["name"]
- for i, v in ipairs(oklist) do
- if v == checkname then
- return true
- end
- end
- return false
- end
- function digoutWait(side)
- term.clear()
- term.setCursorPos(1,1)
- write("Plz DigOut NG Blocks")
- repeat
- sleep(1)
- until not turtle["detect"..side]()
- end
- function colorWrite(str,color)
- if term.isColor() then
- term.setTextColor(color)
- end
- write(str)
- if term.isColor() then
- term.setTextColor(colors.white)
- end
- end
- function cdig(side)
- if side == nil then
- side = ""
- end
- if checkNG(side) then
- digoutWait(side)
- end
- if not checkOK(side) then
- term.clear()
- term.setCursorPos(1,1)
- local ok,data = turtle["inspect"..side]()
- colorWrite( data["name"], colors.red)
- if side == "" then
- write(" on ")
- colorWrite("Front",colors.orange)
- else
- write(" on ")
- colorWrite(side,colors.orange)
- end
- write(" is unknown block...\nI can dig it?(y/n)\n")
- while true do
- local mes = {os.pullEvent("key")}
- if mes[2] == 21 then ---y
- oklist[#oklist+1] = data["name"]
- addlist("OK.lst",data["name"])
- colorWrite("add list",colours.green)
- break
- end
- if mes[2] == 49 then ---n
- nglist[#nglist+1] = data["name"]
- addlist("NG.lst",data["name"])
- digoutWait(side)
- break
- end
- end
- end
- turtle["dig"..side]()
- end
- init()
- while true do
- cdig()
- turtle.forward()
- cdig("Up")
- cdig("Down")
- if not turtle.detect() then
- turtle.turnLeft()
- if not turtle.detect() then
- break
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement