abc123mewot

Pnematiccraft compressor monitor

Jan 8th, 2018
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.06 KB | None | 0 0
  1. os.loadAPI("utils")
  2. os.loadAPI("buttons")
  3.  
  4. local mon = peripheral.wrap("right")
  5. local compressors = {
  6.   ["Alpha compressor"] = {
  7.     comp = utils.fcmpr(0)
  8.   }
  9. }
  10.  
  11. function drawCompressor(mon, cmp, cmpName)
  12.   local temp = utils.kelvinToCelcius(cmp.getTemperature())
  13.   local pres = cmp.getPressure()
  14.    
  15.   local tCol = colors.red;
  16.   local pCol = colors.red;
  17.  
  18.   if temp < -100 then tCol = colors.blue
  19.   elseif temp < -50 then tCol = colors.lime
  20.   elseif temp < 0 then tCol = colors.yellow
  21.   else tCol = colors.red end
  22.   if pres < 30 then pCol = colors.red
  23.   elseif pres < 20 then pCol = colors.lime
  24.   elseif pres < 10 then pCol = colors.yellow
  25.   elseif pres < 5 then pCol = colors.orange end
  26.    
  27.   utils.printCentLn(mon, "--------" .. cmpName .. "--------")
  28.   utils.monWrt(mon, "Temperature: " .. temp .. " C", tCol)
  29.   utils.monNLCR(mon)
  30.   utils.monWrt(mon, "Pressure: " .. pres .. " bar", pCol)
  31.   utils.monNLCR(mon)
  32. end
  33.  
  34. while true do
  35.   for k, v in pairs(compressors) do
  36.     drawCompressor(mon, v.comp, k)
  37.   end
  38.   sleep(0.25)
  39.   utils.rstMon(mon)
  40. end
Advertisement
Add Comment
Please, Sign In to add comment