Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if not fs.exists("button") then
- shell.run("pastebin get LTDZZZEJ button")
- end
- if not fs.exists("dsa") then
- shell.run("pastebin get J9mhuXuf dsa")
- end
- local m = peripheral.find("monitor")
- local b = require("button").monitor
- local data = require("dsa")
- local items = {}
- local startsize = {m.getSize()}
- local maxitems = startsize[2] - 3
- local updaterate = 0.5
- if not fs.exists("tdl.data") then
- fs.open("tdl.data", "w").close()
- end
- for i = 1, maxitems do
- items[i] = data.getLine("tdl.data", i)
- if items[i] == "" then
- items[i] = nil
- break
- end
- end
- local function centerWrite(text, customY, term)
- local width = term.getSize()
- term.setCursorPos(math.ceil((width / 2) - (text:len() / 2)), customY)
- term.write(text)
- end
- m.clear()
- m.setCursorPos(1, 1)
- local function tdl()
- centerWrite("To do list", 1, m)
- centerWrite("------------------", 2, m)
- end
- while true do
- local click = b.timetouch(updaterate, peripheral.getName(m))
- m.clear()
- tdl()
- do
- local width = m.getSize()
- local text = ">create items<"
- if b.button("top", click, math.ceil((width / 2) - (text:len() / 2)), 3, text) then
- centerWrite("create new item in", 4, m)
- centerWrite("computer terminal", 5, m)
- local count = 1
- for i = 1, #items do
- count = count + 1
- end
- items[count] = read()
- data.writeLine("tdl.data", count, items[count])
- end
- end
- for k, v in ipairs(items) do
- local text = v
- local width = m.getSize()
- if b.button("top", click, math.ceil((width / 2) - (text:len() / 2)), k + 3, text) then
- items[k] = nil
- items = data.ser(items)
- fs.open("tdl.data", "w").close()
- for i = 1, #items do
- data.writeLine("tdl.data", i, items[i])
- end
- end
- end
- end
Add Comment
Please, Sign In to add comment