View difference between Paste ID: LVrY28kj and 5d2FV0CF
SHOW: | | - or go back to the newest paste.
1
--[[ICBM Launch Server]]--
2
 
3
size = {term.getSize()}
4
 
5-
users = {"Andrew2070"}
5+
users = {"IFactaOG"}
6-
passwords = {"3765"}
6+
passwords = {"7676"}
7
admin = {"Admin"}
8
adminpassword = {"1999"}
9
10
local silos = {}
11
 
12
--[[Functions]]--
13
14
rednet.open("top")
15
local waitDelay = 2
16
17
local function red()
18
term.setBackgroundColor(colors.red)
19
print("                                                          ")
20
term.setBackgroundColor(colors.blue)
21
end
22
23
local function findSilos()
24
    rednet.broadcast("ping silo")
25
 
26
  local timerID = os.startTimer(waitDelay)
27
 
28
  while true do
29
    event, id, msg1, distance = os.pullEvent()
30
   
31
    if event == "rednet_message" and msg1 == "table" then
32
      
33
      silo = textutils.unserialise(msg1)
34
      
35
      timerID = os.startTimer(waitDelay)
36
    elseif event == "timer" and id == timerID then
37
       return
38
    end
39
  end
40
end
41
42
 
43
local curSilo = 1
44
local function launch(count, x, y, z)
45
  local msg = {x = x, y = y, z = z}
46
    print("launching Missiles At " .. x .. ", " .. y .. ", " .. z)
47
      for i = 1, count do
48
        rednet.send(silos[curSilo], msg)
49
          curSilo = (curSilo == #silos) and 1 or (curSilo + 1)
50
            sleep(5)
51
      end
52
end
53
 
54
local function printSilos(silo)
55
  term.clear()
56
  term.setCursorPos(1,1)
57
    print("              [Detected silos]       ")
58
    
59-
    for k, v in ipairs(silos) do
59+
    print(silo[1], silo[2], silo[3])
60-
    print("              silo #" .. k .. " id = "..v)
60+
61
  --  for k, v in ipairs(silos) do
62
  --  print("              silo #" .. k .. " id = "..v)
63
  end
64
--end
65
end
66
 
67
 
68
 
69
function drawBoxPos(x,y,x1,y1)
70
  cy = y
71
  term.setCursorPos(x,y)
72
  for i = 1,(y1-y)+1 do
73
    for i = 1,(x1-x) do
74
      term.write(" ")
75
    end
76
    cy = cy+1
77
    term.setCursorPos(x,cy)
78
  end
79
end
80
 
81
function reset()
82
  term.setBackgroundColor(colors.lightGray)
83
  term.setCursorPos(2,12)
84
  for i = 1,size[1]-4 do
85
    term.write(" ")
86
  end
87
  term.setTextColor(colors.gray)
88
  term.setBackgroundColor(colors.gray)
89
  drawBoxPos(9,8,size[1]-1,8)
90
  term.setBackgroundColor(colors.lightGray)
91
  term.setCursorPos(3,8)
92
  print("USER:")
93
  term.setBackgroundColor(colors.gray)
94
  drawBoxPos(9,10,size[1]-1,10)
95
  term.setBackgroundColor(colors.lightGray)
96
  term.setCursorPos(3,10)
97
  print("PASS:")
98
end
99
 
100
function loginScreen()
101
  term.setBackgroundColor(colors.white)
102
  term.clear()
103
  term.setBackgroundColor(colors.lightGray)
104
  drawBoxPos(2,2,size[1],size[2]-1)
105
  term.setCursorPos(1,size[2]-7)
106
  term.setBackgroundColor(colors.gray)
107
  drawBoxPos(((size[1]/2)-10)-1,2,((size[1]/2)+13)-1,4)
108
  term.setBackgroundColor(colors.red)
109
  drawBoxPos((size[1]/2)-10,1,(size[1]/2)+13,3)
110
  term.setTextColor(colors.gray)
111
  str = "Skynet Mainframe"
112
  term.setCursorPos((size[1]/2)-(#str/2) +1,2)
113
  term.write(str)
114
  term.setBackgroundColor(colors.lightGray)
115
  str = "Enter Authentication Credentials"
116
  term.setCursorPos((size[1]/2)-(#str/2) +1,6)
117
  term.write(str)
118
  term.setBackgroundColor(colors.gray)
119
  drawBoxPos(9,8,size[1]-1,8)
120
  term.setBackgroundColor(colors.lightGray)
121
  term.setCursorPos(3,8)
122
  print("USER:")
123
  term.setBackgroundColor(colors.gray)
124
  drawBoxPos(9,10,size[1]-1,10)
125
  term.setBackgroundColor(colors.lightGray)
126
  term.setCursorPos(3,10)
127
  print("PASS:")
128
  term.setBackgroundColor(colors.red)
129
  drawBoxPos(((size[1]/2)-9)-1,13,((size[1]/2)+13)-1,15)
130
  term.setTextColor(colors.gray)
131
  str = "Login to Skynet!"
132
  term.setCursorPos((size[1]/2)-(#str/2) +1,14)
133
  term.write(str)
134
  term.setBackgroundColor(colors.lightGray)
135
  str = "(c) 2016 Skynet - Build. Innovate. Conquer"
136
  term.setCursorPos((size[1]/2)-(#str/2) +1,size[2]-2)
137
  term.write(str)
138
  while true do
139
    evnt = {os.pullEvent()}
140
    if evnt[1] == "mouse_click" then
141
      if evnt[3] > 8 and evnt[3] < size[1]-1 and evnt[4] == 8 then
142
        term.setBackgroundColor(colors.gray)
143
        term.setTextColor(colors.lightGray)
144
        term.setCursorPos(9,8)
145
        username = read()
146
      elseif evnt[3] > 8 and evnt[3] < size[1]-1 and evnt[4] == 10 then
147
        term.setBackgroundColor(colors.gray)
148
        term.setTextColor(colors.lightGray)
149
        term.setCursorPos(9,10)
150
        password = read("*")
151
      elseif evnt[3] > ((size[1]/2)-9)-2 and evnt[3] < ((size[1]/2)+13)-2 and evnt[4] > 12 and evnt[4] < 16 then
152
        if username ~= nil and password ~= nil then
153
          loggedin = false
154
          for i = 1,#users do
155
            if username == users[i] then
156
              if password == passwords[i] then
157
                term.setTextColor(colors.lime)
158
                term.setBackgroundColor(colors.lightGray)
159
                str = "Access Granted. Welcome back, "..username
160
                term.setCursorPos((size[1]/2)-(#str/2) +1,12)
161
                term.write(str)
162
                loggedin = true
163
                sleep(3)
164
      elseif evnt[3] > ((size[1]/2)-9)-2 and evnt[3] < ((size[1]/2)+13)-2 and evnt[4] > 12 and evnt[4] < 16 then
165
        if username ~= nil and password ~= nil then
166
          loggedin = false
167
          for i = 1,#users do
168
            if admin == users[i] then
169
              if adminpassword == passwords[i] then
170
              error()
171
              end
172
            end
173
          end
174
          if loggedin then
175
term.setBackgroundColor(colors.blue)
176
term.clear()
177
findSilos()
178
term.setCursorPos(1,1)
179
term.setBackgroundColor(colors.blue)
180
term.clear()
181
  printSilos(silo)
182
red()
183
write("Enter Launch Verification Code: ")
184
  input  = read()
185
red()
186
  term.setBackgroundColor(colors.blue)
187
  if input == "exit" then
188
   break
189
    elseif input == "949-854-3444" then
190
     while true do
191-
print("        [Target Selection]       ")
191+
192
red()
193
       write("Launch Confirmation [Yes/No]: ")
194
        input2 = read()
195
       if input2 == "No" then
196
      os.reboot()
197
   elseif input2 == "Yes" then
198
 local count, x, y, z
199
  while not (type(count) == "number" and type(x) == "number" and type(y) == "number" and type(z) == "number") do
200
red()
201
print("      [Target Selection]       ")
202
red()
203
term.setBackgroundColor(colors.blue)
204-
print("    Target Selection Complete:")
204+
205
      count = tonumber(read())
206
      print("Coordinates:")
207
      write("X: ")
208
      x = tonumber(read())
209
      write("Y: ")
210
      y = tonumber(read())
211
      write("Z: ")
212
      z = tonumber(read())
213
sleep(1)
214
Print("Target Selection Complete:")
215
 red()
216
term.setBackgroundColor(colors.blue)
217
   print("Launching at: "..x..","..y..","..z)
218
   print("Launching Missiles -T Minus 10 Seconds.")
219
   sleep(1)
220
red()
221
   
222
sleep(1)
223
write("  Abort [Yes/No]: ")
224
local abort = read()
225
if abort == "Yes" then
226
write("Warheads Disarmed Successfully")
227
sleep(1)
228
write("Session Expired, renewing login:")
229
sleep(2)
230
os.reboot()
231
elseif abort == "No" then
232
    end
233
    launch(count, x, y, z)
234
    sleep(10)
235
    os.reboot()
236
end
237
          elseif loggedin == false then
238
            term.setTextColor(colors.red)
239
            term.setBackgroundColor(colors.lightGray)
240
            str = "Username or Password incorrect."
241
            term.setCursorPos((size[1]/2)-(#str/2) +1,12)
242
            term.write(str)
243
            sleep(2)
244
            reset()
245
          end
246
          end
247
        elseif username == nil or password == nil then
248
          reset()
249
          term.setTextColor(colors.red)
250
          term.setBackgroundColor(colors.lightGray)
251
          str = "Username or Password not recognized."
252
          term.setCursorPos((size[1]/2)-(#str/2) +1,12)
253
          term.write(str)
254
          sleep(2)
255
          reset()
256
        end
257
      end
258
    end
259
  end
260
end
261
end
262
end
263
264
loginScreen()
265
term.setBackgroundColor(colors.black)
266
term.clear()
267
term.setCursorPos(1,1)