TheYellowBush

setup.lua

Jul 20th, 2025 (edited)
416
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.41 KB | None | 0 0
  1. -- AE2 Stockpile Manager - Setup Helper
  2. -- v1
  3. -- Helps configure auto-start and validates installation
  4.  
  5. local function checkFile(filename)
  6.     if fs.exists(filename) then
  7.         return true
  8.     else
  9.         return false
  10.     end
  11. end
  12.  
  13. local function showHeader()
  14.     term.clear()
  15.     term.setCursorPos(1, 1)
  16.     print("=== AE2 Stockpile Setup ===")
  17.     print()
  18. end
  19.  
  20. local function checkInstallation()
  21.     showHeader()
  22.     print("Checking installation...")
  23.     print()
  24.    
  25.     local files = {
  26.         "ae2_main.lua",
  27.         "ae2_config.lua",
  28.         "ae2_display.lua",
  29.         "ae2_interface.lua",
  30.         "ae2_menu.lua"
  31.     }
  32.    
  33.     local allPresent = true
  34.    
  35.     for _, file in pairs(files) do
  36.         if checkFile(file) then
  37.             print("[OK] " .. file)
  38.         else
  39.             print("[MISSING] " .. file)
  40.             allPresent = false
  41.         end
  42.     end
  43.    
  44.     print()
  45.     if allPresent then
  46.         print("Installation complete! All files found.")
  47.         return true
  48.     else
  49.         print("Installation incomplete. Please download missing files.")
  50.         return false
  51.     end
  52. end
  53.  
  54. local function configureAutoStart()
  55.     showHeader()
  56.     print("Auto-Start Configuration")
  57.     print()
  58.    
  59.     if checkFile("startup.lua") then
  60.         print("startup.lua already exists.")
  61.         write("Overwrite existing startup.lua? (y/n): ")
  62.         local confirm = read()
  63.         if confirm:lower() ~= "y" then
  64.             return
  65.         end
  66.     end
  67.    
  68.     print("Setting up auto-start...")
  69.    
  70.     -- Copy startup script content (simplified for this example)
  71.     local startupContent = [[-- AE2 Stockpile Auto-Start
  72. term.clear()
  73. term.setCursorPos(1, 1)
  74. print("=== AE2 Stockpile Auto-Start ===")
  75. print("Starting in 3 seconds... (Ctrl+T to cancel)")
  76. os.sleep(3)
  77. shell.run("ae2_main.lua", "auto")
  78. ]]
  79.    
  80.     local file = fs.open("startup.lua", "w")
  81.     if file then
  82.         file.write(startupContent)
  83.         file.close()
  84.         print("Auto-start configured successfully!")
  85.         print()
  86.         print("The AE2 Stockpile Manager will now start automatically")
  87.         print("when this computer boots up.")
  88.     else
  89.         print("ERROR: Could not create startup.lua")
  90.     end
  91. end
  92.  
  93. local function disableAutoStart()
  94.     if checkFile("startup.lua") then
  95.         fs.delete("startup.lua")
  96.         print("Auto-start disabled. startup.lua removed.")
  97.     else
  98.         print("Auto-start is not currently enabled.")
  99.     end
  100. end
  101.  
  102. local function showMainMenu()
  103.     showHeader()
  104.     print("1. Check Installation")
  105.     print("2. Enable Auto-Start")
  106.     print("3. Disable Auto-Start")
  107.     print("4. Run AE2 Stockpile Manager")
  108.     print("5. Run AE2 Stockpile Manager (Auto Mode)")
  109.     print("6. Exit Setup")
  110.     print()
  111.     write("Select option: ")
  112.     return read()
  113. end
  114.  
  115. local function main()
  116.     while true do
  117.         local choice = showMainMenu()
  118.        
  119.         if choice == "1" then
  120.             checkInstallation()
  121.             print()
  122.             print("Press any key to continue...")
  123.             os.pullEvent("key")
  124.         elseif choice == "2" then
  125.             if checkInstallation() then
  126.                 print()
  127.                 print("Press any key to continue...")
  128.                 os.pullEvent("key")
  129.                 configureAutoStart()
  130.                 print()
  131.                 print("Press any key to continue...")
  132.                 os.pullEvent("key")
  133.             else
  134.                 print()
  135.                 print("Please install all required files first.")
  136.                 print("Press any key to continue...")
  137.                 os.pullEvent("key")
  138.             end
  139.         elseif choice == "3" then
  140.             disableAutoStart()
  141.             print()
  142.             print("Press any key to continue...")
  143.             os.pullEvent("key")
  144.         elseif choice == "4" then
  145.             if checkFile("ae2_main.lua") then
  146.                 shell.run("ae2_main.lua")
  147.             else
  148.                 print("ae2_main.lua not found!")
  149.                 os.sleep(2)
  150.             end
  151.         elseif choice == "5" then
  152.             if checkFile("ae2_main.lua") then
  153.                 shell.run("ae2_main.lua", "auto")
  154.             else
  155.                 print("ae2_main.lua not found!")
  156.                 os.sleep(2)
  157.             end
  158.         elseif choice == "6" then
  159.             break
  160.         end
  161.     end
  162.    
  163.     showHeader()
  164.     print("Setup complete!")
  165. end
  166.  
  167. main()
Advertisement
Add Comment
Please, Sign In to add comment