Advertisement
Corbinhol

Glasses API

Sep 25th, 2022 (edited)
882
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.20 KB | None | 0 0
  1. local glasses = peripheral.wrap("top");
  2. rednet.open("right");
  3. local protocol = "API";
  4. local furnaceStatus = "Offline";
  5.  
  6. glasses.clear();
  7. function main()
  8.     while true do
  9.         local address = rednet.lookup("API", "FurnaceSystem");
  10.         if address ~= nil then
  11.             rednet.send(address, "getFurnaceData", protocol);
  12.             local from, message = rednet.receive(protocol, 1);
  13.             furnaceStatus = message;
  14.             if furnaceStatus == nil then furnaceStatus = "Offline" end
  15.             print(furnaceStatus);
  16.         end
  17.         sleep(0);
  18.     end
  19. end
  20.  
  21. function updateGlasses()
  22.     while true do
  23.         glasses.clear();
  24.         glasses.drawString("Furnace Status: ", 7, 200, 0xFFFFFF);
  25.         -- if furnaceStatus == "Offline" then  
  26.         --     glasses.drawString("Offline             ", 90, 200, 0xFF0000);
  27.         -- elseif furnaceStatus == "Partially Online" then
  28.         --     glasses.drawString("Partially Online          ", 90, 200, 0xFF9700);
  29.         -- elseif  furnaceStatus == "Online" then
  30.         --     glasses.drawString("Online             ", 90, 200, 0x00FF00);
  31.         -- end
  32.         sleep(1)
  33.     end
  34. end
  35.  
  36. parallel.waitForAny(main, updateGlasses);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement