Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- modem = peripheral.wrap("left");
- time = ""
- outputFile = "log";
- count = 0;
- monitor = {}
- state = false;
- modem.open(28812);
- --Functions
- function addMonitor(...)
- local monList = peripheral.getNames();
- for i,m in ipairs(monList) do
- local curr = peripheral.wrap(m);
- if peripheral.getType(m) == "monitor" and curr.isColour() == true then
- print("Found monitor on side: " .. m);
- state = true;
- monitor[0] = {
- peripheral = curr;
- }
- end;
- end;
- end;
- function getTime(...)
- local web = http.get("http://api.timezonedb.com/v2/get-time-zone?key=NV11PJAS1020&format=json&by=zone&zone=America/Los_Angeles").readAll();
- time = string.sub(web,276,283);
- end;
- --Pre
- addMonitor();
- logFile = fs.open(outputFile,"a");
- logFile.writeLine("----------------------------");
- logFile.close();
- while true do
- local event,modemSide,senderChannel,replyChannel,message,senderDistance = os.pullEvent("modem_message");
- getTime();
- str = time .. " | " .. message;
- logFile = fs.open(outputFile,"a");
- --print(str);
- if state == true then
- monitor[0].peripheral.clear();
- monitor[0].peripheral.setCursorPos(1,1);
- monitor[0].peripheral.write(str);
- end;
- logFile.writeLine(str);
- logFile.close();
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement