Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mSide = "right"
- function readLines(sPath)
- -- reads the users file as raw text and returns it in a table.
- file = fs.open(sPath, "r")
- if file then
- tLines = {}
- sLine = file.readLine()
- while sLine do
- table.insert(tLines, sLine)
- sLine = file.readLine()
- end
- file.close()
- return tLines
- end
- return nil
- end
- -- Uses a table of text and writes it to the users file.
- function writeLines(sPath, tLines)
- local file = fs.open(sPath, "w")
- if file then
- for _, sLine in ipairs(tLines) do
- file.writeLine(tostring(sLine))
- end
- file.close()
- else
- error(sPath .. " does not exist")
- end
- end
- function mPrint(s)
- win.print(s)
- -- m.write(s)
- -- mx,my=m.getCursorPos()
- -- m.setCursorPos(1,my+1)
- end
- function center(s)
- mx,my = win.getCursorPos()
- m.setCursorPos(math.floor((w/2)-(#s/2)),my)
- print(s)
- end
- function updateMonitor()
- win.clear()
- win.setCursorPos(1,1)
- t = term.redirect(win)
- center("TODO LIST")
- center("---------")
- for i=1,#currentlist do
- print(i .." " ..currentlist[i])
- end
- term.redirect(t)
- end
- m=peripheral.find("monitor")
- m.setTextScale(1)
- x,y = term.getSize()
- w,h = m.getSize()
- win = window.create(m,1,1,w,h)
- currentlist = {}
- if fs.exists("autolist") then
- currentlist = readLines("autolist")
- end
- while true do
- updateMonitor()
- term.clear()
- term.setCursorPos(1,1)
- print("Type in what needs to be done then hit enter, or type 'read' to see a current list")print("To clear an entry, first type 'rm' then hit enter, then enter the number that coresponds to the entry you wish to remove. Use 'read' to get this number")
- term.write("> ")
- input = io.read()
- if input == "read" then
- term.clear()
- term.setCursorPos(1,1)
- print("Current List Includes:")
- for i=1,#currentlist do
- print(i .." " ..currentlist[i])
- end
- sleep(4)
- term.setCursorPos(1,y-1)
- write("Press Any Key to Continue")
- while true do
- e,k = os.pullEvent("key")
- if e == "key" then
- break
- end
- end
- term.clearLine()
- sleep(1)
- elseif input == "exit" then
- writeLines("autolist",currentlist)
- print("Exiting")
- sleep(2)
- break
- elseif input == "rm" then
- print("Remove which number?")
- rm = io.read()
- if tonumber(rm)> #currentlist then
- print("Entry Number " .. " does not exist")
- else
- print("Removed " .. currentlist[tonumber(rm)])
- table.remove(currentlist,tonumber(rm))
- writeLines("autolist",currentlist)
- end
- sleep(3)
- else
- table.insert(currentlist,input)
- writeLines("autolist",currentlist)
- print("Added Entry:")
- print(input)
- sleep(5)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment