Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- term.clear()
- term.setCursorPos(1, 1)
- local side = nil
- for _, s in pairs(rs.getSides()) do
- if peripheral.getType(s) == "monitor" then
- side = s
- end
- end
- m = peripheral.wrap(side)
- local x
- local y
- x, y = m.getSize()
- local page = 1
- m = peripheral.wrap("right")
- local things = {""}
- function saveAll()
- local file = fs.open("tasks", "w")
- file.write(textutils.serialize(things))
- file.close()
- end
- function loadAll()
- local file = fs.open("tasks", "r")
- local data = file.readAll()
- file.close()
- data = textutils.unserialize(data)
- for i = 1, #data do
- things[i] = data[i]
- end
- end
- function mainLoop()
- loadAll()
- m.clear()
- printTop()
- for i = 1, y-2 do
- printLine(i)
- end
- printButtons()
- term.clear()
- term.setCursorPos(1, 1)
- term.setTextColor(colors.white)
- print("Chcesz dodac czy usunac notatke?")
- term.setTextColor(colors.lime)
- term.write(" Dodaj")
- term.setTextColor(colors.red)
- print(" Usun")
- term.setTextColor(colors.white)
- event, a, b, c = os.pullEvent()
- if event == "mouse_click" then
- if c == 2 then
- if (b == 3) or (b >= 4) and (b <= 7) then
- print("")
- print("Co chcesz zrobic?")
- task = read()
- things[#things+1] = task
- saveAll()
- sleep(0.2)
- print("Zadanie dodane!")
- sleep(0.5)
- elseif (c == 13) or (b >= 13) and (b <= 25) then
- print("")
- print("Ktore zadanie chcesz usunac? (Podaj liczbe)")
- task = read()
- print("Na pewno? (t/n)")
- answ = read()
- if (answ == "t") or (answ == "T") then
- print("Usunieto " ..task)
- for i = task, #things - 1 do
- things[i] = things[i+1]
- end
- things[#things] = nil
- saveAll()
- sleep(0.2)
- print("Notatka usunieta!")
- sleep(0.5)
- end
- end
- end
- end
- if event == "monitor_touch" then
- if c == y then
- if (b == 2) or (b == 3) or (b == 4) or (b ==5) then
- if page > 1 then
- page = page-1
- end
- elseif (b == x-4) or (b == x-3) or (b == x-2) or (b == x-1) then
- page = page+1
- end
- end
- end
- mainLoop()
- end
- function printButtons()
- m.setCursorPos(2, y)
- if page == 1 then
- m.setTextColor(colors.lightGray)
- else
- m.setTextColor(colors.black)
- end
- m.setBackgroundColor(colors.white)
- m.write("Wstecz")
- m.setTextColor(colors.black)
- m.setCursorPos(x/2, y)
- m.write("" ..page)
- m.setCursorPos(x-4, y)
- m.write("Dalej")
- end
- function printTop()
- m.setBackgroundColor(colors.white)
- m.setTextColor(colors.black)
- m.setCursorPos(x/2-5, 1)
- m.write("Do zrobienia:")
- end
- function printLine(num)
- if num % 2 == 0 then
- m.setBackgroundColor(colors.gray)
- else
- m.setBackgroundColor(colors.lightGray)
- end
- m.setCursorPos(1, num+1)
- if page > 1 then
- num = num+(x*(page-1))
- end
- m.write("" ..num)
- m.write(": ")
- if things[num] ~= nil then
- m.write("" ..things[num])
- m.write(" ")
- else
- m.write(" ")
- end
- end
- mainLoop()
Add Comment
Please, Sign In to add comment