Advertisement
S3mpx

axoturtle_installer

May 21st, 2024 (edited)
901
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.36 KB | None | 0 0
  1. -- Installer script for AxoTurtle
  2. local configDir = "AxoTurtleConfig"
  3. local devOffFile = configDir .. "/dev_off"
  4.  
  5. -- Function to create a directory if it doesn't exist
  6. local function createDirIfNotExists(dir)
  7.     if not fs.exists(dir) then
  8.         fs.makeDir(dir)
  9.     end
  10. end
  11.  
  12. -- Function to write the development status file
  13. local function writeDevStatus(status)
  14.     local file = fs.open(devOffFile, "w")
  15.     file.write(status)
  16.     file.close()
  17. end
  18.  
  19. -- Create configuration directory and dev_off file
  20. createDirIfNotExists(configDir)
  21. writeDevStatus("off")
  22.  
  23. -- Modify the startup script
  24. local startupScript = "/startup"
  25. local startupCode = [[
  26. -- Existing startup code if any
  27. if fs.exists("startup_backup") then
  28.     shell.run("startup_backup")
  29. end
  30.  
  31. -- AxoTurtle startup additions
  32. local devStatusFile = "]] .. devOffFile .. [["
  33. local function getDevStatus()
  34.     if not fs.exists(devStatusFile) then
  35.         return "off"
  36.     end
  37.     local file = fs.open(devStatusFile, "r")
  38.     local status = file.readAll()
  39.     file.close()
  40.     return status:match("^%s*(.-)%s*$") -- trim whitespace
  41. end
  42.  
  43. local devStatus = getDevStatus()
  44.  
  45. if devStatus == "on" then
  46.     print("Development mode active")
  47.     -- Custom development mode behavior here
  48. else
  49.     print("Production mode active")
  50.     -- Phase 1: Launch Phase
  51.     local function launchPhase()
  52.         print("Running Launch Phase...")
  53.         -- Insert launch phase logic here
  54.     end
  55.  
  56.     -- Phase 2: Idle Phase
  57.     local function idlePhase()
  58.         print("Entering Idle Phase...")
  59.         while true do
  60.             -- Wait for user input or other events
  61.             local event, param = os.pullEvent()
  62.             if event == "key" then
  63.                 -- Process user input
  64.                 print("Key pressed:", param)
  65.                 -- Phase 3: Action Phase
  66.                 actionPhase()
  67.             end
  68.         end
  69.     end
  70.  
  71.     -- Phase 3: Action Phase
  72.     local function actionPhase()
  73.         print("Performing Action...")
  74.         -- Insert action phase logic here
  75.     end
  76.  
  77.     launchPhase()
  78.     idlePhase()
  79. end
  80. ]]
  81.  
  82. -- Backup existing startup script
  83. if fs.exists(startupScript) then
  84.     fs.copy(startupScript, "startup_backup")
  85. end
  86.  
  87. -- Write new startup script
  88. local file = fs.open(startupScript, "w")
  89. file.write(startupCode)
  90. file.close()
  91.  
  92. print("AxoTurtle installed successfully!")
  93.  
Advertisement
Comments
  • bairi
    12 days
    # text 0.09 KB | 0 0
    1. can u add me bro i have questions
    2. https://steamcommunity.com/profiles/76561199091249086
Add Comment
Please, Sign In to add comment
Advertisement