Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Inventory Monitor
- local uptime = 1;
- local gui = require("SmallGUI");
- local storage = peripheral.wrap("bottom");
- local protocol = "AUTOBUYER"
- local uptime = 0;
- rednet.open("top");
- rednet.host("StorageSystem", protocol);
- local currentLog = {};
- function getData()
- while true do
- address, message = rednet.receive(protocol);
- if message == "sendInventoryData" then
- log("Recieved Message From " .. address);
- rednet.send(address, textutils.serialize(storage.list()), protocol);
- end
- sleep(0);
- end
- end
- function log(input)
- local tempOut = "[" .. gui.parseTime(uptime) .. "] " .. input;
- table.insert(currentLog, tempOut);
- end
- function setUptime()
- while true do uptime = uptime + 1; sleep(1) end
- end
- function updateScreen()
- while true do
- gui.printf(string.rep("=", term.getSize()),1,1);
- gui.printf("Inventory Monitor: [Ver 2.0]", 1, 2)
- gui.printf("| Uptime: " .. gui.parseTime(uptime));
- gui.printf(string.rep("=", term.getSize()),1,3);
- for i = 1, 15, 1 do
- tableLength = table.getn(currentLog);
- if currentLog[tableLength - i] ~= nil then
- gui.printf(currentLog[tableLength - i] .. string.rep(" ", term.getSize()), 1, 3+i);
- end
- end
- sleep(0);
- end
- end
- gui.reset();
- parallel.waitForAny(getData, setUptime, updateScreen);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement