Maldaris

Untitled

Jan 16th, 2016
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.22 KB | None | 0 0
  1.  
  2. function init(type)
  3. local mon = nil;
  4. local defaultTermLocation = {
  5. x = nil, y = nil;
  6. }
  7. local update = nil;
  8. local reset = nil;
  9. local function newline(m)
  10. px , py = m.getCursorPos();
  11. m.setCursorPos(1,py+1);
  12. end
  13. if type == "securityMonitor" then
  14. mon = peripheral.wrap("monitor_1");
  15. mon.setTextScale(1);
  16. mon.setBackgroundColor(colors.black);
  17. mon.setTextColor(colors.green);
  18. termx, termy = mon.getSize();
  19. defaultTermLocation.x = 1;
  20. defaultTermLocation.y = 1;
  21. mon.setCursorPos(defaultTermLocation.x, defaultTermLocation.y);
  22. update = function(m, text)
  23. m.write(text.."\n");
  24. newline(m);
  25. end
  26. reset = function(m)
  27. m.clear();
  28. m.setBackgroundColor(colors.black);
  29. m.setTextColor(colors.green);
  30. m.setCursorPos(defaultTermLocation.x, defaultTermLocation.y);
  31. end
  32. else
  33. mon = peripheral.wrap("monitor_2");
  34. mon.setTextScale(0.5);
  35. mon.setBackgroundColor(colors.black);
  36. mon.setTextColor(colors.green);
  37. termx , termy = mon.getSize();
  38. defaultTermLocation.x = 1;
  39. defaultTermLocation.y = math.floor(termy/2);
  40. mon.setCursorPos(defaultTermLocation.x, defaultTermLocation.y);
  41. update = function(m, valid, name)
  42. if valid == true then
  43. m.write("CLEARED\n");
  44. newline(m);
  45. m.write("Welcome "..name.."\n");
  46. else
  47. m.setBackgroundColor(colors.red);
  48. m.setTextColor(colors.white);
  49. m.write("DENIED\n");
  50. newline(m);
  51. if name ~= nil then
  52. m.write("Reason: "..name.."\n");
  53. end
  54. end
  55. end;
  56. reset = function(m,d)
  57. m.clear();
  58. m.setBackgroundColor(colors.black);
  59. m.setTextColor(colors.green);
  60. m.setCursorPos(d.x, d.y);
  61. end;
  62. end
  63. local ret = {};
  64. ret.mon = mon;
  65. ret.type = type;
  66. ret.defaultTermLocation = defaultTermLocation;
  67. ret._r = reset;
  68. ret._u = update;
  69. function ret:reset()
  70. self._r(self.mon, self.defaultTermLocation);
  71. end;
  72. function ret:update(valid, name)
  73. self._u(self.mon, valid, name);
  74. end;
  75. function ret:versionPrompt()
  76. self.mon.write("EREBUS AUTHENTICATION SERVER V1.0");
  77. newline(self.mon);
  78. end
  79. return ret;
  80. end
Add Comment
Please, Sign In to add comment