Advertisement
Guest User

terminal

a guest
Oct 21st, 2017
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.10 KB | None | 0 0
  1. local monitor = peripheral.wrap("left")
  2. local tick = 0
  3. local msgId = 0
  4.  
  5. function writeMsg()
  6.   msg = "unkown"
  7.   x = 0
  8.  
  9.   if msgId == 101 then msg = "Initialization..." x = 18
  10.   elseif msgId == 102 then msg = "Terminate request" x = 18
  11.  
  12.   elseif msgId == 301 then msg = "No network connection" x = 17
  13.   elseif msgId == 302 then msg = "Terminated" x = 21 end
  14.  
  15.   monitor.setCursorPos(x, 10)
  16.   monitor.write(msg)
  17. end
  18.  
  19. function redraw()
  20.   tick = tick + 1
  21.  
  22.   monitor.clear()
  23.   monitor.setCursorPos(20, 4)
  24.   monitor.setTextScale(1)
  25.   monitor.setTextColor(colors.white)
  26.   monitor.write("ShE3py's Home")
  27.  
  28.   if msgId ~= 0 then
  29.     oldColor = monitor.getTextColor()
  30.     if msgId < 200 then monitor.setTextColor(colors.lightBlue)
  31.     elseif msgId < 300 then monitor.setTextColor(colors.orange)
  32.     elseif msgId < 400 then monitor.setTextColor(colors.red) end
  33.    
  34.     if msgId < 200 then writeMsg()
  35.     elseif tick % 2 == 0 then writeMsg() end
  36.    
  37.     monitor.setTextColor(oldColor)
  38.   end
  39. end
  40.  
  41. function setMsgId(id)
  42.   msgId = id
  43.  
  44.   redraw()
  45. end
  46.  
  47. function getMsgId()
  48.   return msId
  49. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement