SHOW:
|
|
- or go back to the newest paste.
1 | local pullEvent = os.pullEvent | |
2 | os.pullEvent = os.pullEventRaw | |
3 | ||
4 | function clear() | |
5 | term.setCursorPos(1,1) | |
6 | term.clear() | |
7 | end | |
8 | ||
9 | clear() | |
10 | ||
11 | ||
12 | local setpass --for setting the password | |
13 | local adminpass -- for setting the admin password | |
14 | local opentime -- for setting how long the door will stay open | |
15 | local rootpass -- for setting the rootpass | |
16 | local redstoneOutputSide | |
17 | local args = {...} | |
18 | ||
19 | if fs.exists("doorlock-settings") and args[1] ~= "reset" then | |
20 | local f = fs.open("doorlock-settings", "r") | |
21 | setpass = f.readLine() | |
22 | adminpass = f.readLine() | |
23 | rootpass = f.readLine() | |
24 | opentime = tonumber(f.readLine()) | |
25 | redstoneOutputSide = f.readLine() | |
26 | f.close() | |
27 | else | |
28 | print("Please define the password to gain access to the door:") | |
29 | setpass = read("*") | |
30 | clear() | |
31 | ||
32 | print("Please define the password to gain root access to the computer(to edit files):") | |
33 | rootpass = read("*") | |
34 | clear() | |
35 | ||
36 | print("Please define the admin password. This password will keep the door open when entered") | |
37 | adminpass = read("*") | |
38 | clear() | |
39 | ||
40 | print("Please define the amount of time the redstone pulse will be on:") | |
41 | opentime = tonumber(read()) | |
42 | clear() | |
43 | ||
44 | local vside = false | |
45 | while true do | |
46 | print("Which side is the door on?") | |
47 | redstoneOutputSide = read() | |
48 | for k,v in pairs(rs.getSides()) do | |
49 | if v == redstoneOutputSide then | |
50 | vside = true | |
51 | break | |
52 | end | |
53 | end | |
54 | if vside then break end | |
55 | print("Invalid side!") | |
56 | sleep(0.5) | |
57 | clear() | |
58 | end | |
59 | local f = fs.open("doorlock-settings", "w") | |
60 | f.writeLine(setpass) | |
61 | f.writeLine(adminpass) | |
62 | f.writeLine(rootpass) | |
63 | f.writeLine(tostring(opentime)) | |
64 | f.writeLine(redstoneOutputSide) | |
65 | f.close() | |
66 | end | |
67 | ||
68 | while true do | |
69 | clear() | |
70 | print ("Loading...") | |
71 | print ("Done Loading!") | |
72 | sleep(1) | |
73 | term.clear() | |
74 | term.setCursorPos(1,1) | |
75 | ||
76 | print ("Door Lock v0.5") | |
77 | print ("Coded by Joeman05") | |
78 | write "Passcode: " | |
79 | input = read("*") | |
80 | if input == setpass then | |
81 | print ("Access Granted") | |
82 | rs.setBundledOutput(redstoneOutputSide, colors.magenta) | |
83 | sleep(1) | |
84 | rs.setBundledOutput(redstoneOutputSide, 0) | |
85 | sleep(1) | |
86 | rs.setBundledOutput(redstoneOutputSide, colors.magenta) | |
87 | sleep(1) | |
88 | rs.setBundledOutput(redstoneOutputSide, 0) | |
89 | sleep(1) | |
90 | rs.setBundledOutput(redstoneOutputSide, colors.magenta) | |
91 | sleep(1) | |
92 | rs.setBundledOutput(redstoneOutputSide, 0) | |
93 | - | sleep(opentime) |
93 | + | |
94 | rs.setBundledOutput(redstoneOutputSide, colors.magenta) | |
95 | sleep(1) | |
96 | rs.setBundledOutput(redstoneOutputSide, 0) | |
97 | sleep(1) | |
98 | rs.setBundledOutput(redstoneOutputSide, colors.magenta) | |
99 | sleep(1) | |
100 | rs.setBundledOutput(redstoneOutputSide, 0) | |
101 | sleep(1) | |
102 | rs.setBundledOutput(redstoneOutputSide, colors.magenta) | |
103 | sleep(1) | |
104 | rs.setBundledOutput(redstoneOutputSide, 0) | |
105 | sleep(opentime) | |
106 | - | rs.setBundledOutput(redstoneOutputSide, 0) |
106 | + | |
107 | sleep(1) | |
108 | rs.setBundledOutput(redstoneOutputSide, 0) | |
109 | sleep(1) | |
110 | rs.setBundledOutput(redstoneOutputSide, colors.orange) | |
111 | sleep(1) | |
112 | rs.setBundledOutput(redstoneOutputSide, 0) | |
113 | sleep(1) | |
114 | rs.setBundledOutput(redstoneOutputSide, colors.orange) | |
115 | sleep(1) | |
116 | rs.setBundledOutput(redstoneOutputSide, 0) | |
117 | sleep(1) | |
118 | rs.setBundledOutput(redstoneOutputSide, colors.orange) | |
119 | sleep(1) | |
120 | rs.setBundledOutput(redstoneOutputSide, 0) | |
121 | sleep(1) | |
122 | rs.setBundledOutput(redstoneOutputSide, colors.orange) | |
123 | sleep(1) | |
124 | rs.setBundledOutput(redstoneOutputSide, 0) | |
125 | sleep(1) | |
126 | rs.setBundledOutput(redstoneOutputSide, colors.orange) | |
127 | sleep(1) | |
128 | rs.setBundledOutput(redstoneOutputSide, 0) | |
129 | os.shutdown() | |
130 | elseif input == adminpass then | |
131 | print ("Door will remain open, remember to close!") | |
132 | rs.setOutput(redstoneOutputSide, true) | |
133 | while true do | |
134 | term.clear() | |
135 | write "Passcode: " | |
136 | input2 = read("*") | |
137 | if input2 == adminpass then | |
138 | rs.setOutput(redstoneOutputSide, false) | |
139 | os.shutdown() | |
140 | break | |
141 | end | |
142 | end | |
143 | elseif input == rootpass then | |
144 | textutils.slowPrint ("Welcome, you may now edit the programs/files on this computer!") | |
145 | term.clear() | |
146 | os.pullEvent = pullEvent | |
147 | print ("Root permissions enabled") | |
148 | return | |
149 | else | |
150 | print ("Uhhm... Wrong password..") | |
151 | sleep(2) | |
152 | os.shutdown() | |
153 | end | |
154 | end |