MarcosKoco

PassW

Jun 5th, 2021 (edited)
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.83 KB | None | 0 0
  1. local Version = "1.0.0"
  2. local ComputerVersion = "1.0.0"
  3.  
  4. local System = os -- Used for System things like os.time() to System.time()
  5. local Screen = term -- Used for Screen thing on the turtle or computer like term.clear() to Screen.clear()
  6. local Per = peripheral -- Used shortcut for peripheral
  7. local Text = textutils -- Used shortcut for textilils
  8. local Pack = Text.serialize -- Makes a new command for packing ( shortcut used from local Text)
  9. local UnPack = Text.unserialize -- Makes a new command for unpacking ( shortcut used from local Text)
  10.  
  11. local OldpullEvent = System.pullEvent
  12. System.pullEvent = System.pullEventRaw
  13.  
  14. local file = fs.exists("/API/Functions.lua")
  15.  
  16. if not(file) then
  17.    
  18.     shell.run("pastebin get sujHjqXC /API/Functions.lua")
  19.    
  20. end
  21.  
  22. System.loadAPI("/API/Functions.lua")
  23.  
  24. local Modem = Per.wrap(Functions.FindWirelessModem())
  25. local Send = Modem.transmit
  26. Modem.closeAll()
  27.  
  28. local Monitor = Per.wrap(Functions.FindMonitor())
  29.  
  30. local Computer = { ComputerName = "Test_Computer",
  31.                 Status = true,
  32.                 LogOn = false
  33.                 }
  34.                
  35. System.setComputerLabel(Computer.ComputerName)
  36.  
  37. function Startup()
  38.    
  39.     if not(Modem) then
  40.        
  41.         print("No WirelessModem Found !")
  42.         error()
  43.        
  44.     end
  45.    
  46.     Temp()
  47.    
  48. end
  49.  
  50. function DelTemp()
  51.    
  52.     fs.delete("OS/Temp/Temp.Tem")
  53.    
  54. end
  55.  
  56. function Temp()
  57.    
  58.     if fs.exists("OS/Temp/Temp.Tem") then
  59.        
  60.         File = fs.open("OS/Temp/Temp.Tem", "r")
  61.         Data = UnPack(File.readAll())
  62.         File.close()
  63.        
  64.         Computer.ComputerName = Data.ComputerName
  65.         Computer.LogOn = Data.LogOn
  66.         Computer.Status = Data.Status
  67.         Computer.UserName = Data.UserName
  68.        
  69.     end
  70.    
  71. end
  72.  
  73. Screen.clear()
  74. Screen.setCursorPos(1, 1)
  75.  
  76. Startup()
  77.  
  78. local w, h = Screen.getSize()
  79. local NameLen = 17
  80. local nOption = 1
  81. local MaxOptions = 3
  82.  
  83. function drawMenu()
  84.    
  85.     Screen.clear()
  86.     Screen.setCursorPos(1, 1)
  87.     Screen.write("Base 01")
  88.    
  89.     Screen.setCursorPos(w-(NameLen+3), 1)
  90.    
  91.     if nOption == 1 then
  92.        
  93.         Screen.write("Make Account")
  94.        
  95.     elseif nOption == 2 then
  96.    
  97.         Screen.write("Login")
  98.        
  99.     elseif nOption == 3 then
  100.        
  101.         Screen.write("Shutdown")
  102.        
  103.     else
  104.        
  105.     end
  106.    
  107. end
  108.  
  109. Screen.clear()
  110.  
  111. function drawFrontend()
  112.    
  113.     Functions.printCentered(math.floor(h/2) -3, "")
  114.     Functions.printCentered(math.floor(h/2) -2, Functions.PadString("  Head Menu",NameLen))
  115.     Functions.printCentered(math.floor(h/2) -1, "")
  116.     Functions.printCentered(math.floor(h/2) +0, ((nOption == 1) and string.format("%s%s",Functions.PadString("[ Make Account",NameLen-1),"]") or Functions.PadString("  Make Account",NameLen)))
  117.     Functions.printCentered(math.floor(h/2) +1, ((nOption == 2) and string.format("%s%s",Functions.PadString("[ Login",NameLen-1),"]") or Functions.PadString("  Login",NameLen)))
  118.     Functions.printCentered(math.floor(h/2) +2, ((nOption == 3) and string.format("%s%s",Functions.PadString("[ Shutdown",NameLen-1),"]") or Functions.PadString("  Shutdown",NameLen)))
  119.    
  120. end
  121.  
  122. function onEnter()
  123.    
  124.     if nOption == 1 then
  125.        
  126.         shell.run("OS/.Make")
  127.         Temp()
  128.         Screen.clear()
  129.         drawMenu()
  130.         drawFrontend()
  131.        
  132.     elseif nOption == 2 then
  133.        
  134.         shell.run("OS/.Login")
  135.         Temp()
  136.         Screen.clear()
  137.         drawMenu()
  138.         drawFrontend()
  139.        
  140.     elseif nOption == 3 then
  141.        
  142.         DelTemp()
  143.         System.shutdown()
  144.        
  145.     end
  146.    
  147. end
  148.  
  149. drawMenu()
  150. drawFrontend()
  151.  
  152. while not(Computer.LogOn) do
  153.    
  154.     local Event, p1, p2, p3, p4, p5 = System.pullEvent()
  155.    
  156.     if Event == "key" then
  157.        
  158.         if p1 == keys.up or p1 == keys.numPad8 then
  159.            
  160.             if nOption > 1 then
  161.                
  162.                 nOption = nOption - 1
  163.                 drawMenu()
  164.                 drawFrontend()
  165.                
  166.             end
  167.            
  168.         elseif p1 == keys.down or p1 == keys.numPad2 then
  169.            
  170.             if nOption < MaxOptions then
  171.                
  172.                 nOption = nOption + 1
  173.                 drawMenu()
  174.                 drawFrontend()
  175.                
  176.             end
  177.            
  178.         elseif p1 == keys.enter or p1 == keys.numPadEnter then
  179.            
  180.             onEnter()
  181.            
  182.         end
  183.        
  184.     end
  185.    
  186. end
  187.    
  188. shell.run("OS/.Menu")
  189.  
  190.  
  191.  
Advertisement
Add Comment
Please, Sign In to add comment