Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rednet.open("back") ------ turn off for ios, internet option instead
- w, h = term.getSize()
- term.clear()
- term.setCursorPos(1, 1)
- messages = {}
- --text formatters--
- function partition()
- term.setBackgroundColor(colors.gray)
- term.setTextColor(colors.white)
- end
- function emphasis()
- term.setBackgroundColor(colors.lightGray)
- term.setTextColor(colors.white)
- end
- function background()
- term.setBackgroundColor(colors.white)
- term.setTextColor(colors.black)
- end
- --initialize header--
- if h % 3 == 1 then
- inbox = 2
- else
- inbox = 1
- end
- --unserialize--
- function unserialize(string)
- --print(string)
- local run = loadstring(string)
- --pcall(run())
- run()
- for i, v in pairs(messages) do
- print(i, v)
- end
- --sleep(20)
- end
- --tick--
- local day = tostring(os.day())
- local time = tostring(os.time())
- local updateTick = 0
- function update()
- updateTick = updateTick + 1
- if updateTick >= 10 then
- day = tostring(os.day())
- time = tostring(os.time())
- updateTick = 0
- end
- getMsglist()
- os.cancelTimer(timer)
- timer = os.startTimer(.1)
- end
- function getMsglist()
- rednet.broadcast("", "getmsglist")
- end
- --program start--
- location = 0
- dir = 0
- timer = os.startTimer(.1)
- while true do
- getMsglist()
- --print("L: " .. location)
- if #messages > 6 then
- if location > -1 * math.abs(1 + #messages - h / 3) and location <= 0 then
- location = location + dir
- end
- if location == 1 then location = 0 end
- if location < -1 * math.abs(1 + #messages - h / 3) then location = location + 1 end
- end
- background()
- term.clear()
- partition()
- term.setCursorPos(1, 2)
- term.clearLine()
- background()
- term.setCursorPos((w / 2 - 5 / 2) + 1, inbox)
- write("Inbox")
- term.setCursorPos(1, 2)
- partition()
- term.write(day .. ":" .. time)
- y = 1
- --if messages then
- for i = 1, #messages do
- if (-1 * tonumber(i) > -1 * (h / 3) + location and -1 * tonumber(i) < location) then
- emphasis()
- term.setCursorPos(1, y * 3)
- print(i .. "| " .. messages[i][2])
- background()
- print(messages[i][1])
- y = y + 1
- end
- end
- --end
- pressed = {}
- dir = 0
- local events = {os.pullEvent()}
- if events[1] == "timer" then
- update()
- elseif events[1] == "mouse_scroll" then
- dir = events[2]
- elseif events[1] == "rednet_message" then
- if events[4] == "sendmsglist" then
- unserialize(events[3])
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement