Advertisement
Guest User

startup

a guest
Aug 6th, 2016
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.30 KB | None | 0 0
  1. os.pullEvent = os.pullEventRaw
  2. function LoadWifi()
  3.   local listOfSides = rs.getSides()
  4.   local listofPossibles = {}
  5.   local counter1 = 0
  6.   while true do
  7.     counter1 = counter1 + 1
  8.  
  9.     if peripheral.isPresent(tostring(listOfSides[counter1])) and peripheral.getType(listOfSides[counter1]) == "modem" then
  10.       table.insert(listofPossibles,tostring(listOfSides[counter1]))
  11.     end
  12.    
  13.     if counter1 == 6 and table.maxn(listofPossibles) == 0 then
  14.       return nil
  15.     end
  16.    
  17.     if counter1 == 6 and table.maxn(listofPossibles) ~= 0 then
  18.       rednet.open(listofPossibles[1])
  19.       return listofPossibles[1]
  20.     end
  21.   end
  22. end
  23. function LoadDiskDrive()
  24.   local listOfSides = rs.getSides()
  25.   local listOfPossibles = {}
  26.   local counter = 0
  27.   while true do
  28.     counter = counter + 1
  29.    
  30.     if peripheral.isPresent(tostring(listOfSides[counter])) and peripheral.getType(listOfSides[counter]) == "drive" then
  31.       table.insert(listOfPossibles,tostring(listOfSides[counter]))
  32.     end
  33.    
  34.     if counter == 6 and table.maxn(listOfPossibles) == 0 then
  35.       return nil
  36.     end
  37.    
  38.     if counter == 6 and table.maxn(listOfPossibles) ~= 0 then
  39.       return listOfPossibles[1]
  40.     end
  41.   end
  42. end
  43. function LoadPrinter()
  44.   local listOfSides = rs.getSides()
  45.   local listOfPossibles = {}
  46.   local counter = 0
  47.   while true do
  48.       counter = counter + 1
  49.      
  50.       if peripheral.isPresent(tostring(listOfSides[counter])) and peripheral.getType(listOfSides[counter]) == "printer" then
  51.         table.insert(listOfPossibles,tostring(listOfSides[counter]))
  52.       end
  53.      
  54.       if counter == 6 and table.maxn(listOfPossibles) == 0 then
  55.         return nil
  56.       end
  57.      
  58.       if counter == 6 and table.maxn(listOfPossibles) ~= 0 then
  59.         return listOfPossibles[1]
  60.       end
  61.   end
  62. end
  63. function Welcome()
  64.   term.clear()
  65.   term.setCursorPos(1,1)
  66.   print("Welcome " .. username)
  67. end
  68.  
  69. modemOn = LoadWifi()
  70. DiskDriveOn = LoadDiskDrive()
  71. PrinterOn = LoadPrinter()
  72.  
  73. term.clear()
  74. term.setCursorPos(1,1)
  75.  
  76. if modemOn == nil then
  77.   term.setTextColor(colors.red)
  78.   print("No Wifi Modem")
  79.   term.setTextColor(colors.white)
  80. else
  81.   term.setTextColor(colors.green)
  82.   print("Connected to wifi")
  83.   print("Opened wifi on " .. modemOn .. " side")
  84.   term.setTextColor(colors.white)
  85. end
  86.  
  87. if DiskDriveOn == nil then
  88.   term.setTextColor(colors.red)
  89.   print("no disk drive")
  90.   term.setTextColor(colors.white)
  91. else
  92.   term.setTextColor(colors.green)
  93.   print("Opened disk drive on " .. DiskDriveOn .. " side")
  94.   term.setTextColor(colors.white)
  95. end
  96.  
  97. if PrinterOn == nil then
  98.   term.setTextColor(colors.red)
  99.   print("No printer")
  100.   term.setTextColor(colors.white)
  101. else
  102.   term.setTextColor(colors.green)
  103.   print("Printer found on " .. PrinterOn .. " side")
  104.   term.setTextColor(colors.white)
  105. end
  106. sleep(1)
  107. term.clear()
  108. term.setCursorPos(1,1)
  109.  
  110. local loadicon = paintutils.loadImage("loadicon")
  111. paintutils.drawImage(loadicon, 3, 5)
  112.  
  113. sleep(1)
  114. term.setBackgroundColor(colors.black)
  115. term.clear()
  116. term.setCursorPos(1,1)
  117. local x, y = term.getSize()
  118. for yPos = 1, y do
  119.   term.setBackgroundColor(colors.gray)
  120.   term.setCursorPos(1, yPos)
  121.   for xPos = 1, x do
  122.     print(" ")
  123.   end
  124. end
  125. term.setTextColor(colors.white)
  126. local w, h = term.getSize()
  127. term.setCursorPos(w / 2 - 11 / 2, 3)
  128. print("OpenGate Os")
  129.  
  130. function drawTextBar()
  131.   term.setBackgroundColor(colors.white)
  132.   local wT1, hT1 = term.getSize() / 2 - 5
  133.   local wT2, hT2 = term.getSize() / 2 + 5
  134.   term.setCursorPos(wT1,5)
  135.   for w = wT1, wT2 do
  136.     write(" ")
  137.   end
  138.   term.setCursorPos(wT1,7)
  139.   for w = wT1, wT2 do
  140.     write(" ")
  141.   end
  142. end
  143. while true do
  144.   local wT1, hT1 = term.getSize() / 2 - 5
  145.   local wT2, hT2 = term.getSize() / 2 + 5
  146.   term.setCursorPos(wT1,5)
  147.   drawTextBar()
  148.   term.setTextColor(colors.black)
  149.   term.setCursorPos(w / 2 - 5, 5)
  150.   user = read()
  151.   term.setCursorPos(w / 2 - 5, 7)
  152.   pass = read("*")
  153.   if user == "pete456" and pass == "shit" then
  154.     term.setBackgroundColor(colors.black)
  155.     term.setTextColor(colors.white)
  156.     term.setCursorPos(1,1)
  157.     term.clear()
  158.     print("Welcome pete456")
  159.     break
  160.   else
  161.     term.setBackgroundColor(colors.gray)
  162.     term.setCursorPos(1,1)
  163.     term.setTextColor(colors.red)
  164.     print("Incorrect username or password")
  165.     term.setTextColor(colors.white)
  166.   end
  167. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement