Advertisement
Guest User

LP_Receiver

a guest
May 22nd, 2015
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.66 KB | None | 0 0
  1. -------------------------
  2. -- LPnet monitor program1.0
  3.  
  4. --------setting-----------
  5. storageComputerID = 19
  6. maxStrageSize = 16
  7. reactorComputerID = 12
  8. fontColor = colors.white
  9. accentColor = colors.lightGray
  10.  
  11. --------function-----------
  12. function accent(accx,accy,acccolor,accmes)
  13.  if accx ~= 0 then mon.setCursorPos(accx,accy) end
  14.  mon.setTextColor(acccolor)
  15.  mon.write(accmes)
  16. end
  17.  
  18.  
  19.  
  20. function message(x,y,infcolor,mes1,inf,mes2)
  21.  if x ~= 0 then mon.setCursorPos(x,y) end
  22.  mon.setTextColor(fontColor)
  23.  mon.write(mes1)
  24.  mon.setTextColor(infcolor)
  25.  mon.write(inf)
  26.  mon.setTextColor(fontColor)
  27.  mon.write(mes2)
  28. end
  29.  
  30. function gauge(x1,y1,x2,y2,color1,color2,value,maxValue)
  31.     valuex = (x2-x1)*value/maxValue + x1
  32.     for X = x1,x2 do
  33.         for Y = y1,y2 do
  34.             mon.setBackgroundColor(color2)
  35.             mon.setCursorPos(X,Y)
  36.             mon.write(" ")
  37.         end
  38.     end
  39.     if value ~= 0 then
  40.      for X = x1,valuex do
  41.         for Y = y1,y2 do
  42.             mon.setBackgroundColor(color1)
  43.             mon.setCursorPos(X,Y)
  44.             mon.write(" ")
  45.         end
  46.      end
  47.     end
  48.    
  49.    
  50.     mon.setBackgroundColor(colors.black)
  51. end
  52.  
  53. function timeInf()
  54.  time = os.time()
  55.  time_str = textutils.formatTime(time)
  56.  
  57.  if time > 6 and time < 18.5 then
  58.    mon.setTextColor(colors.yellow)
  59.  else
  60.    mon.setTextColor(colors.blue)
  61.  end
  62.  
  63.  mon.setCursorPos(1,1)
  64.  mon.clearLine()
  65.  mon.write(time_str)
  66. end
  67.  
  68.  
  69.  
  70. -----------main--------------------
  71. for k, v in pairs(peripheral.getNames()) do
  72.     if string.find(peripheral.getType(v),"Logi") == 1 then
  73.       LP = peripheral.wrap(v)
  74.     end
  75. end
  76. mon = peripheral.find("monitor")
  77.  
  78. mon.setBackgroundColor(colors.black)
  79. mon.clear()
  80. mon.setTextScale(0.5)
  81.  
  82. while true do
  83.  timeInf()
  84.  state = {}
  85.  state[1],state[2],state[3] = os.pullEvent("LP_MESSAGE")
  86.  if state[2] == storageComputerID then
  87.     mon.setCursorPos(2,2)
  88.     mon.clearLine()
  89.     accent(2,2,accentColor,"Storage")
  90.     if state[3] < 0 then
  91.         accent(0,2,colors.cyan," waiting turtle")
  92.     else
  93.  
  94.         LC = (state[3]-math.floor(state[3]))*1000
  95.         filledLC = math.floor(state[3])/1000
  96.         if filledLC/LC > 0.8 then
  97.             message(0,2,colors.red," : ",string.format("%d",filledLC),"/")    
  98.         else
  99.             message(0,2,colors.lime," : ",string.format("%d",filledLC),"/")
  100.         end
  101.         message(0,0,colors.white,"",string.format("%d",LC),"LC")
  102.         gauge(20,2,30,2,colors.lime,colors.gray,filledLC,LC)
  103.     end
  104.  end
  105.  if state[2] == reactorComputerID then
  106.     accent(2,4,accentColor,"Reactor")
  107.     message(0,4,colors.lime," : ",string.format("%d",state[3]),"RF/Tick")
  108.  end
  109.  sleep(1)
  110. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement