Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function init(type)
- local mon = nil;
- local defaultTermLocation = {
- x = nil, y = nil;
- }
- local update = nil;
- local reset = nil;
- local function newline(m)
- px , py = m.getCursorPos();
- m.setCursorPos(1,py+1);
- end
- if type == "securityMonitor" then
- mon = peripheral.wrap("monitor_1");
- mon.setTextScale(1);
- mon.setBackgroundColor(colors.black);
- mon.setTextColor(colors.green);
- termx, termy = mon.getSize();
- defaultTermLocation.x = 1;
- defaultTermLocation.y = 1;
- mon.setCursorPos(defaultTermLocation.x, defaultTermLocation.y);
- update = function(m, text)
- m.write(text.."\n");
- newline(m);
- end
- reset = function(m)
- m.clear();
- m.setBackgroundColor(colors.black);
- m.setTextColor(colors.green);
- m.setCursorPos(defaultTermLocation.x, defaultTermLocation.y);
- end
- else
- mon = peripheral.wrap("monitor_2");
- mon.setTextScale(0.5);
- mon.setBackgroundColor(colors.black);
- mon.setTextColor(colors.green);
- termx , termy = mon.getSize();
- defaultTermLocation.x = 1;
- defaultTermLocation.y = math.floor(termy/2);
- mon.setCursorPos(defaultTermLocation.x, defaultTermLocation.y);
- update = function(m, valid, name)
- if valid == true then
- m.write("CLEARED\n");
- newline(m);
- m.write("Welcome "..name.."\n");
- else
- m.setBackgroundColor(colors.red);
- m.setTextColor(colors.white);
- m.write("DENIED\n");
- newline(m);
- if name ~= nil then
- m.write("Reason: "..name.."\n");
- end
- end
- end;
- reset = function(m,d)
- m.clear();
- m.setBackgroundColor(colors.black);
- m.setTextColor(colors.green);
- m.setCursorPos(d.x, d.y);
- end;
- end
- local ret = {};
- ret.mon = mon;
- ret.type = type;
- ret.defaultTermLocation = defaultTermLocation;
- ret._r = reset;
- ret._u = update;
- function ret:reset()
- self._r(self.mon, self.defaultTermLocation);
- end;
- function ret:update(valid, name)
- self._u(self.mon, valid, name);
- end;
- function ret:versionPrompt()
- self.mon.write("EREBUS AUTHENTICATION SERVER V1.0");
- newline(self.mon);
- end
- return ret;
- end
Add Comment
Please, Sign In to add comment