PeeWeeSweden

ComputerCraft.systemMonitor

Oct 9th, 2013
587
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.32 KB | None | 0 0
  1. --[ System Monitor ]--
  2.  
  3.  
  4. --[ VARS ]--
  5. net = peripheral.wrap("right")
  6. mon = peripheral.wrap("top")
  7.  
  8. --[ FUNCTIONS ]
  9. function listMFSU()
  10.     local sReturn = ""
  11.     local units = {"rcsteeltankvalvetile_1"}
  12.     term.clear()
  13.     term.setCursorPos(1,1)
  14.     print("Name    Stored/Capacity")
  15.        
  16.     for i=1,3 do
  17.         sReturn = string.format("%8s %7d/%7d (%3d%%)",
  18.             units[i],
  19.             net.callRemote(units[i],"getEUStored"),
  20.             net.callRemote(units[i],"getEUCapacity"),
  21.             net.callRemote(units[i],"getEUStored")/net.callRemote("mfsu_0","getEUCapacity")*100)
  22.  
  23.         print(sReturn)        
  24.     end
  25.     listOilTank()
  26. end
  27.  
  28. function listOilTank()
  29.     local valve  = peripheral.wrap("rcsteeltankvalvetile_1")
  30.     local tableInfo = valve.getTankInfo("unknown")
  31.     local lines = 0
  32.    
  33.     mon.clear()
  34.     mon.setCursorPos(1,1)
  35.     mon.write("rcsteeltankvalvetile_1")
  36.     for k, v in pairs(tableInfo) do
  37.         for x, y in pairs(v) do
  38.             if x == "amount" or x == "capacity" then
  39.                 lines = lines + 1
  40.                 mon.setCursorPos(1,lines +1)
  41.                 mon.write(lines..". "..x..": "..y)
  42.             end
  43.         end
  44.     end
  45. end
  46.  
  47. function run()
  48.     while true do
  49.        listOilTank()
  50.        sleep(10)
  51.     end
  52. end
  53.  
  54. --[ MAIN ]--
  55. run()
Advertisement
Add Comment
Please, Sign In to add comment