Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.loadAPI("/blackboard/blackBoard")
- function display(t)
- local x, y = t.getSize()
- t.clear()
- t.setCursorPos(1, 1)
- for i = 1, x do
- t.blit(" ", "0", "7")
- end
- t.setCursorPos(1, 1)
- t.blit("id", "00", "77")
- t.setCursorPos(4, 1)
- t.blit("from", "0000", "7777")
- t.setCursorPos(x / 4 + 4, 1)
- t.blit("to", "00", "77")
- t.setCursorPos(x / 2 + 3, 1)
- t.blit("message", "0000000", "7777777")
- blackBoard.load("/todo.bb")
- for i = 1, blackBoard.maxid() do
- local from, to, what = blackBoard.select(i)
- t.setCursorPos(1, i + 1)
- t.write(tostring(i))
- t.setCursorPos(4, i + 1)
- t.write(from)
- t.setCursorPos(x / 4 + 4, i + 1)
- t.write(to)
- t.setCursorPos(x / 2 + 3, i + 1)
- t.write(what)
- end
- end
- function main()
- local mon = peripheral.wrap("left")
- mon.setTextScale(0.5)
- display(mon)
- display(term)
- local x, y = term.getSize()
- blackBoard.load("/todo.bb")
- while true do
- term.setCursorPos(1, y)
- term.write("Command: ")
- local command = io.read()
- if command == "insert" then
- display(mon)
- display(term)
- term.setCursorPos(1, y)
- term.write("from: ")
- local from = io.read()
- display(mon)
- display(term)
- term.setCursorPos(1, y)
- term.write("to: ")
- local to = io.read()
- display(mon)
- display(term)
- term.setCursorPos(1, y)
- term.write("what: ")
- local what = io.read()
- blackBoard.insert(from, to, what)
- elseif command == "delete" then
- display(mon)
- display(term)
- term.setCursorPos(1, y)
- term.write("id: ")
- local id = io.read()
- blackBoard.delete(tonumber(id))
- elseif command == "update" then
- display(mon)
- display(term)
- term.setCursorPos(1, y)
- term.write("id: ")
- local id = io.read()
- display(mon)
- display(term)
- term.setCursorPos(1, y)
- term.write("from: ")
- local from = io.read()
- if from == "" then
- from = nil
- end
- display(mon)
- display(term)
- term.setCursorPos(1, y)
- term.write("to: ")
- local to = io.read()
- if to == "" then
- to = nil
- end
- display(mon)
- display(term)
- term.setCursorPos(1, y)
- term.write("what: ")
- local what = io.read()
- if what == "" then
- what = nil
- end
- print(from)
- blackBoard.update(tonumber(id), from, to, what)
- elseif command == "exit" then
- mon.clear()
- term.clear()
- return
- end
- display(mon)
- display(term)
- end
- end
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement