Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local component = require("component");
- local event = require("event");
- local computer = require("computer");
- local redstone = component.redstone;
- local gpu = component.gpu;
- local modem = component.modem;
- local InPort = 114;
- local OutPort = 1984;
- local CommPort = 3666;
- local Captain = "Aex";
- local userlist = {};
- local TrustedAddr = "";
- modem.open(InPort);
- local resX = 30
- local resY = 10
- gpu.setResolution(resX, resY);
- local sMode = 1; -- -1 - Wait Menu, 0 - Admin, 1 - Main Menu,
- local cTask = 0; -- 0 - Nothing, 1 - Door open, 2 - Message pending
- local TimeOut = 0;
- local sCL = 0;
- local GuestName = "";
- local timestamp = computer.uptime();
- local DefMsg = " WELCOME TO METROPOLIS"
- local RSside = 3;
- local Defcon = 4; -- 5 - open doors, _4_ - Only friends, 3 - Only owner, 2 - Ignore, radar sweeps, 1 - Exterminate
- local MailBlock = -1; -- 0 - allowed, 1 - blocked
- modem.setStrength(0);
- function getUptime(tTime)
- local tTime = computer.uptime();
- local tDays = math.floor(tTime/86400);
- local tHours = math.floor((tTime%86400)/3600);
- local tMinutes = math.floor((tTime%3600)/60);
- local tSeconds = math.floor(tTime%60);
- return tDays.."d, "..tHours..":"..tMinutes..":"..tSeconds;
- end
- function ClrScr()
- gpu.setBackground(0x000000);
- gpu.fill(1,1, resX, resY, " ");
- end
- function ClrMsg()
- gpu.setBackground(0x000000);
- gpu.setForeground(0xFFFFFF);
- gpu.fill(2, 2, 28, 3, " ");
- end
- function DisplayMsg(msg, line)
- gpu.setBackground(0x000000);
- gpu.setForeground(0xFFFFFF);
- gpu.fill(2, line+1, 28, 1, " ");
- gpu.set(2, line+1, tostring(msg));
- end
- function DisplayDefMsg()
- ClrMsg();
- DisplayMsg(DefMsg, 2, 0);
- end
- function OpenDoor()
- redstone.setOutput(3, 16);
- cTask = 1;
- WaitMenu(3);
- end
- function ShowMenu()
- ClrScr();
- -- Draw message pane
- gpu.setForeground(0xFFFFFF);
- gpu.fill(1,1,resX, 1, "=");
- gpu.fill(1,2,1,3,"|");
- gpu.fill(resX,2,1,3,"|");
- gpu.fill(1,5,resX,1,"=");
- gpu.set(10, 1, "METROPOLIS");
- --gpu.set(3, 3, "WELCOME TO METROPOLIS");
- -- Draw buttons
- gpu.setBackground(0xFFFFFF);
- gpu.setForeground(0x000000);
- gpu.fill(2,7,12,3, " ");
- gpu.fill(16,7,12,3, " ");
- -- Button captions
- gpu.set(7, 8, "VISIT");
- gpu.set(18, 8, "MSG");
- gpu.setForeground(0xFFFFFF);
- gpu.setBackground(0x000000);
- DisplayDefMsg();
- TimeOut = 0;
- sMode = 1;
- cTask = 0;
- end
- function AdminMenu()
- end
- function WaitMenu(delay)
- sMode = -1;
- TimeOut = delay;
- timestamp = computer.uptime();
- gpu.fill(1,7, resX, resY, " ");
- gpu.set(8, 9, "PLEASE WAIT");
- end
- function InitHost()
- end
- function InitRobot()
- end
- function VisitRequest()
- sGuestName = GuestName;
- if (GuestName == Captain) then
- DisplayMsg("Welcome back, "..Captain.."!", 1);
- OpenDoor();
- WaitMenu(3);
- end;
- end
- function MsgRequest()
- end
- ShowMenu();
- while true do
- local msg = {event.pull(1)};
- if (msg[1] == "touch") then
- GuestName = msg[6];
- if (msg[4] < 3) and (msg[6] == Captain) then
- AdminMenu();
- else
- if (sMode == 1) and (msg[4] > 6) then
- -- Main Menu
- if (msg[3] < 15) then
- -- VISIT
- VisitRequest(msg[6]);
- else
- MsgRequest(msg[6]);
- end
- end
- end
- end -- IF Event
- if (computer.uptime() - timestamp > TimeOut) and (TimeOut > 0) then
- if (cTask == 1) then
- redstone.setOutput(3, 0);
- elseif (cTask == 2) then
- modem.close(CommPort);
- modem.setStrength(0);
- end
- ShowMenu();
- end
- if (TimeOut == 0) and (redstone.getOutput(3) > 0) then
- redstone.setOutput(3, 0);
- end
- gpu.fill(1, 10, 20, 1, " ");
- gpu.set(1, 10, tostring(getUptime()).." "..tostring(TimeOut));
- os.sleep(0);
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement