Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local m = peripheral.wrap("top")
- m.clear()
- local sx, sy = m.getSize()
- function m.writeError(text)
- m.setBackgroundColor(colors.red)
- m.setCursorPos(1, sy)
- m.write(text)
- m.setBackgroundColor(colors.black)
- end
- function m.print(text)
- local x, y = m.getCursorPos()
- m.write(text)
- m.setCursorPos(1, y+1)
- end
- function drawTaskBar()
- m.clearLine(sy)
- m.clearLine(1)
- m.setCursorPos(1, 1)
- m.write("Day: "..os.day())
- m.setCursorPos(sx-4, 1)
- m.write(textutils.formatTime(os.time(), true))
- m.setCursorPos(1, 2)
- for i=1, sx, 1 do
- m.write("-")
- end
- m.setCursorPos(1, 3)
- end
- function DSUStorage()
- m.print("DSU Storage:")
- rednet.open("bottom")
- local DSUSID = rednet.lookup("LHCP", "DSU_Controller")
- if DSUSID then
- rednet.send(DSUSID, "method:getDSUItems", "LHCP")
- local sID, response = rednet.receive("LHCP", 5)
- if response then
- response = textutils.unserialize(response)
- if tostring(response) and string.find(tostring(response), "error:") then
- m.writeError(response)
- break
- end
- for k, v in ipairs(response) do
- local x, y = m.getCursorPos()
- m.write(v[1])
- m.setCursorPos(15, y)
- m.write(": ")
- m.write(tostring(v[2]))
- m.setCursorPos(1, y+1)
- end
- else
- m.writeError("Connection timed out on DSU_Controller")
- end
- else
- m.writeError("Couldn't connect to DSU_Controller")
- end
- rednet.close("bottom")
- end
- for id=1, 10, 1 do
- drawTaskBar()
- DSUStorage()
- id = 1
- sleep(10)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement