Advertisement
AdamMathieson

Adam's TEV Monitor

Jan 6th, 2022 (edited)
877
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.01 KB | None | 0 0
  1. --
  2. ----       Adam's TEV Monitor
  3. ----  Copyright 2022 Adam Mathieson
  4. --
  5.  
  6. -- Pull in Command Line Args
  7. args = {...}
  8.  
  9. -- Globals
  10. _tevs = {}
  11.  
  12. _dir = "/disk10/TEV/"
  13.  
  14. function Split(s, delimiter)
  15.     result = {};
  16.     for match in (s..delimiter):gmatch("(.-)"..delimiter) do
  17.         table.insert(result, match);
  18.     end
  19.     return result;
  20. end
  21.  
  22. periphs = peripheral.getNames()
  23.  
  24. for _, V in pairs(periphs) do
  25.     if (peripheral.getType(peripheral.wrap(V)) == "Thermal Evaporation Block") then
  26.         tev = peripheral.wrap(V)
  27.         table.insert(_tevs, tev)
  28.         -- File Structure Setup
  29.  
  30.         fs.makeDir(_dir..Split(peripheral.getName(tev), "_")[2].."/")
  31.     end
  32. end
  33.  
  34.  
  35. while true do
  36.     for _, V in pairs(_tevs) do
  37.         file = fs.open(_dir..Split(peripheral.getName(V), "_")[2].."/currentTemp", "w")
  38.         file.writeLine(string.format("%i", V.getTemperature()))
  39.         file.close()
  40.     end
  41.  
  42. -- Yield to system
  43.     os.queueEvent("looperEvent");
  44.     os.pullEvent();
  45.     os.sleep(0.5)
  46. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement