Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- monitor = peripheral.wrap("right")
- monitor.clear()
- local Table = {}
- local function screenRefresh()
- monitor.clear()
- monitor.setCursorPos(1,1)
- local x = 1
- local y = 1
- monitor.write(" THE GRAND TODO LIST!")
- y=y+1
- monitor.setCursorPos(x,y)
- for i = 1,#Table do
- monitor.setCursorPos(x,y)
- monitor.write(i..") "..Table[i])
- y=y+1
- end
- end
- function save(table,name)
- local file = fs.open(name,"w")
- file.write(textutils.serialize(table))
- file.close()
- end
- function load(name)
- local file = fs.open(name,"r")
- local data = file.readAll()
- file.close()
- return textutils.unserialize(data)
- end
- local input = ""
- local numin = 0
- local taskin = ""
- while true do
- screenRefresh()
- print("What would you like to do?")
- print("1) Add new item.")
- print("2) Remove item.")
- print("3) Refresh List.")
- print("4) Restore Data.")
- input = read()
- if (input == "1") and (#Table < 15) then
- print("New Item:")
- taskin = read()
- table.insert(Table, taskin)
- screenRefresh()
- save(Table,"saved")
- elseif #Table > 15 then
- print("Sorry, the list is full!")
- end
- if (input == "2") then
- print("Which item should I remove?")
- numin = tonumber(read())
- if((numin ~= nil) and (numin <= #Table) and (numin >0)) then
- table.remove(Table, numin)
- save(Table,"saved")
- screenRefresh()
- else
- print("That was not a number. Please Enter a number.")
- end
- end
- if (input == "3") then
- screenRefresh()
- end
- if(input == "4") then
- Table = load("saved")
- screenRefresh()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment