Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Controller Boiler Plate
- local protocol = "TEST"; --Do All Caps
- local hostname = "TestClient";
- local modemSide = "back";
- local outputData = {};
- rednet.open(modemSide);
- print("Starting Up Local Monitor Service");
- if os.getComputerLabel() == nil then
- print("System Does Not Have ID...Attempting to obtain one")
- print("Protocol: " .. protocol);
- print("Hostname: " .. hostname);
- local i = 1;
- while true do
- local tempHostname = hostname .. "-" .. i;
- if rednet.lookup(protocol, tempHostname) == nil then
- os.setComputerLabel(tempHostname);
- print("Found Free Name. Set it to " .. tempHostname);
- break;
- end
- i = i + 1;
- end
- end
- function log(value)
- table.insert(outputData, value);
- if table.getn(outputData) >= 15 then
- table.remove(outputData, 1);
- end
- end
- function mainLoop()
- log("1");
- log("2");
- end
- function display()
- shell.run("clear");
- term.setCursorPos(1, 19);
- term.write(string.rep("=", 51));
- while true do
- term.setCursorPos(1,1);
- print(string.rep("=", 51));
- print("Protocol: " .. protocol);
- print("Hostname: " .. os.getComputerLabel());
- print(string.rep("=", 51));
- sleep(.5);
- for t=1, 14, 1 do
- term.clearLine()
- if outputData[t] ~= nil then
- print(outputData[t]);
- end
- end
- sleep(0);
- end
- end
- function modemActivity()
- while true do
- local from, message = rednet.receive(protocol);
- if message == "getdata" then
- local outputData = textutils.serialize(outputData);
- rednet.send(from, outputData);
- log("Recieved Message From " .. from .. " Responding...");
- end
- end
- end
- if os.getComputerLabel() ~= nil then
- rednet.host(protocol, os.getComputerLabel())
- print("Set Hostname");
- end
- parallel.waitForAll(display, modemActivity, mainLoop);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement