LaRRaM

npp_display

Mar 8th, 2021 (edited)
552
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -------------------------------------------------------------------------
  2. local c = require("component");
  3. local term = require("term");
  4. local computer = require("computer");
  5.  
  6. local modem = c.modem;
  7.  
  8. local port = 1314;
  9.  
  10. modem.open(port);
  11.  
  12. local msg = {}; --status, temp, out_energy
  13. local stat, stat1, temp, temp1, energ, energ1;
  14. local disp_stat;
  15. -------------------------------------------------------------------------
  16. while true do
  17.     local name, self_addres, from_addres, port, val4, message = computer.pullSignal();
  18.     if name == "modem_message" then
  19.         for key in message:gmatch("([^;]*)") do
  20.             table.insert(msg, key);
  21.         end
  22.         -- for token in string.gmatch(message, "[^%s]+") do
  23.   --            msg[key] = token;  
  24.         -- end
  25.         stat = msg[1];
  26.         temp = msg[2];
  27.         energ = msg[3];
  28.         for i in pairs(msg) do
  29.             if msg[1] == "EP" then
  30.                 disp_stat = "\033[31mEP\033[0m";
  31.             elseif msg[1] == "ON" then
  32.                 disp_stat = "\033[32mON\033[0m";
  33.             elseif msg[1] == "OFF" then
  34.                 disp_stat = "OFF";
  35.             end
  36. --              if stat1 ~= stat or temp1 ~= temp or energ1 ~= energ then
  37. --              stat1, temp1, energ1 = stat, temp, energ;
  38. --              io.write(stat.." "..temp.." "..energ);
  39.                 print(msg);
  40.                 io.write(stat .. " | " .. temp .. "% | " .. energ);
  41. --              term.clear();
  42. --          end
  43.         end
  44.     end
  45. end
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×