MarcosKoco

ProgsPassW

Jun 5th, 2021 (edited)
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.79 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 file = fs.exists("/Progs/.Data/.Progs.txt")
  25.  
  26. if not(file) then
  27.    
  28.     shell.run("pastebin get SZHXV7Kz /Progs/.Data/.Progs.txt")
  29.    
  30. end
  31.  
  32. file = fs.open("/Progs/.Data/.Progs.txt", "r")
  33. local ProgS = UnPack(file.readAll())
  34. file.close()
  35.  
  36. local Modem = Per.wrap(Functions.FindWirelessModem())
  37. local Send = Modem.transmit
  38. Modem.closeAll()
  39.  
  40. local Monitor = Per.wrap(Functions.FindMonitor())
  41.  
  42. local Computer = { ComputerName = "Test_Computer",
  43.                 Status = true,
  44.                 LogOn = false
  45.                 }
  46.                
  47. System.setComputerLabel(Computer.ComputerName)
  48.  
  49. function Temp()
  50.    
  51.     local Data = Functions.LoadFile("OS/Temp/Temp.Tem")
  52.    
  53.     if Data then
  54.        
  55.         Computer.ComputerName = Data.ComputerName
  56.         Computer.LogOn = Data.LogOn
  57.         Computer.Status = Data.Status
  58.         Computer.UserName = Data.UserName
  59.        
  60.     end
  61.    
  62. end
  63.  
  64. function Startup()
  65.    
  66.     if not(Modem) then
  67.        
  68.         print("No WirelessModem Found !")
  69.         error()
  70.        
  71.     end
  72.    
  73.     Temp()
  74.    
  75. end
  76.  
  77. Screen.clear()
  78. Screen.setCursorPos(1, 1)
  79.  
  80. Startup()
  81.  
  82. local w, h = Screen.getSize()
  83. local NameLen = 17
  84. local nOption = 1
  85. local MaxOptions = #ProgS + 1
  86.  
  87. function drawScreen()
  88.    
  89.     if pocket then
  90.        
  91.         Screen.clear()
  92.         Screen.setCursorPos(1, 1)
  93.         Screen.write("User : "..Computer.UserName)
  94.         Screen.setCursorPos(1, 2)
  95.         Screen.write(Computer.ComputerName)
  96.        
  97.         Screen.setCursorPos(1, 3)
  98.        
  99.     else
  100.        
  101.         Screen.clear()
  102.         Screen.setCursorPos(1, 1)
  103.         Screen.write("User : "..Computer.UserName)
  104.         Screen.setCursorPos(1, 2)
  105.         Screen.write(Computer.ComputerName)
  106.        
  107.         Screen.setCursorPos(w-(NameLen+3), 1)
  108.        
  109.     end
  110.    
  111.     if nOption == MaxOptions then
  112.        
  113.         Screen.write("Back")
  114.        
  115.     else
  116.        
  117.         Screen.write(ProgS[nOption].extra)
  118.        
  119.     end
  120.    
  121.     Functions.printCentered(math.floor(h/2) -3, "")
  122.     Functions.printCentered(math.floor(h/2) -2, Functions.PadString("  Prog's Menu",NameLen))
  123.     Functions.printCentered(math.floor(h/2) -1, "")
  124.    
  125.     local a
  126.    
  127.     for i = 1, #ProgS do
  128.        
  129.         Functions.printCentered(math.floor(h/2) +(i - 1), ((nOption == i) and string.format("%s%s",Functions.PadString("[ "..ProgS[i].name,NameLen-1),"]") or Functions.PadString("  "..ProgS[i].name,NameLen)))
  130.         a = i
  131.        
  132.     end
  133.    
  134.     Functions.printCentered(math.floor(h/2) +a, ((nOption == MaxOptions) and string.format("%s%s",Functions.PadString("[ Back",NameLen-1),"]") or Functions.PadString("  Back",NameLen)))
  135.    
  136. end
  137.  
  138. function onEnter()
  139.    
  140.     if nOption == MaxOptions then
  141.        
  142.         Computer.Status = false
  143.        
  144.     else
  145.        
  146.         shell.run(ProgS[nOption].prog)
  147.         Screen.clear()
  148.        
  149.     end
  150.    
  151. end
  152.  
  153. repeat
  154.    
  155.     drawScreen()
  156.    
  157.     local Event, p1, p2, p3, p4, p5 = System.pullEvent()
  158.    
  159.     if Event == "key" then
  160.        
  161.         if p1 == keys.up or p1 == keys.numPad8 then
  162.            
  163.             if nOption > 1 then
  164.                
  165.                 nOption = nOption - 1
  166.                
  167.             end
  168.            
  169.         elseif p1 == keys.down or p1 == keys.numPad2 then
  170.            
  171.             if nOption < MaxOptions then
  172.                
  173.                 nOption = nOption + 1
  174.                
  175.             end
  176.            
  177.         elseif p1 == keys.enter or p1 == keys.numPadEnter then
  178.            
  179.             onEnter()
  180.            
  181.         end
  182.        
  183.     end
  184.    
  185. until Computer.Status == false
  186.  
  187.  
Advertisement
Add Comment
Please, Sign In to add comment