Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Function to run your custom code
- local function runCustomCode()
- x =
- y =
- z =
- shell.run("gps", "host", x, y, z)
- end
- local function wait()
- os.sleep(4)
- end
- -- Function to reboot the computer
- local function rebootComputer()
- print("Rebooting computer...")
- os.sleep(1) -- Optional: Wait for 1 second before rebooting
- os.reboot() -- Reboot the computer
- end
- -- Function to determine if it's the first run
- local function isFirstRun()
- -- Check if a file indicating the first run exists
- return not fs.exists("first_run")
- end
- -- Function to mark subsequent runs
- local function markFirstRun()
- -- Create a file to mark the first run
- local file = fs.open("first_run", "w")
- file.close()
- end
- -- Function to delete the "first_run" file
- local function deleteFirstRun()
- -- Delete the "first_run" file if it exists
- if fs.exists("first_run") then
- fs.delete("first_run")
- end
- end
- -- Main function to start the process
- local function main()
- -- Check if it's the first run
- if isFirstRun() then
- -- Start the computer
- print("Starting computer...")
- -- Optional: Wait for 1 second before running custom code
- os.sleep(1)
- -- Run your custom code
- parallel.waitForAny(
- function() runCustomCode() end,
- function() wait() end
- )
- -- Mark subsequent runs
- markFirstRun()
- -- Reboot the computer
- rebootComputer()
- else
- -- Delete the "first_run" file
- deleteFirstRun()
- -- Run your custom code directly
- runCustomCode()
- end
- end
- -- Call the main function to start the process
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement