Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Network Explorer
- print("Network Explorer");
- function getMonitor()
- return peripheral.find('monitor');
- end
- function getModem()
- return peripheral.find('modem');
- end
- function split(s, delimiter)
- result = {};
- for match in (s..delimiter):gmatch("(.-)"..delimiter) do
- table.insert(result, match);
- end
- return result;
- end
- print("Searching for modem and monitor");
- modem = getModem();
- if modem == nil then
- print("No modem found");
- exit();
- end
- print("Modem found");
- monitor = getMonitor();
- if monitor == nil then
- print("No monitor found");
- end
- messages = {};
- messageIndex = -1;
- function display()
- local displayWidth, displayHeight = monitor.getSize();
- local firstIndex = messageIndex - displayHeight;
- if firstIndex < 0 then
- firstIndex = 0;
- end
- monitor.clear();
- monitor.setCursorPos(0, 0);
- monitor.write("Network Explorer by Westar");
- for i=firstIndex, messageIndex, 1 do
- monitor.write(messages[i].senderId..","..messages[i].protocol..","..messages[i].message);
- end
- end
- display();
- while true do
- local senderId, message, protocol = rednet.receive();
- messageIndex = messageIndex + 1;
- message[messageIndex] = {
- senderId = senderId,
- message = message,
- protocol = protocol
- };
- display();
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement