Posted 17 September 2018 - 09:59 PM
Why?
I programmed this small script so that my automatically resuming program ([post='278025']OCM[/post]) will only be executed on startup if it has to resume. Otherwise I want whatever the user initially used as startup to be executed.
How do I use it?
You need to install this program as your startup, so make sure that you move any file away from startup if they exist.
To set it up you have access to three functions which you can either type into the terminal or call from another program after loading this as API. as API: as API:
Installation
[anchor='install']Simply type "pastebin get 19VG8eD6 startup" into the terminal.
If you want a program of yours to set up the Startup Handler by itself have a look at this snippet from my program [post='278025']OCM[/post]:
I hope this helps some of you, wether for private use on your computer or to make your programs more independant. I would love to hear some feedback!
Cheers,
Bruno
PS: For moderators: I wasn't sure if this would fit into the subforum "APIs and Utilitys" since it is an executable program and therefore strictly not an API (I think…). If you think so, feel free to move it there.
I programmed this small script so that my automatically resuming program ([post='278025']OCM[/post]) will only be executed on startup if it has to resume. Otherwise I want whatever the user initially used as startup to be executed.
How do I use it?
You need to install this program as your startup, so make sure that you move any file away from startup if they exist.
To set it up you have access to three functions which you can either type into the terminal or call from another program after loading this as API.
getList()
via terminal:startup getList
as API:
startup.getList()
This function returns the externally saved list of programs that should be resumed or executed as standart. Example:
{
"myResumingProgram",
"myOtherResumingProgram",
standart = "myOS",
}
set(path, position)
via terminal:startup set path [position]
startup.set(path, [position])
This function adds the program at path to the list. Optionally you can specify the position where to place the program on the list. Give "standart" as position if you want to change the entry "standart" on the list. Returns boolean successful. If used in the terminal it prints "Success!" + updated List when successful, an error message when not.
remove(path)
via terminal:startup remove path
startup.remove(path)
This function removes the entry path from the list. It can't access "standart" but "startup set ' ' startup" will do the trick. Returns boolean successfull. If used in the terminal prints "Success!" + updated List when successful, error message when not.When executed (normally on startup or after a reboot) this script looks through the list from 1st to last entry if a file exists at path "database/"..listEntry.."/resume". If true it executes that program so that it can resume. If no entry has corresponding resume files the program under the key "standart" is executed.Installation
[anchor='install']Simply type "pastebin get 19VG8eD6 startup" into the terminal.
If you want a program of yours to set up the Startup Handler by itself have a look at this snippet from my program [post='278025']OCM[/post]:
Spoiler
local programName = shell.getRunningProgram()
local function installAsStartup()
if fs.exists("startup") then
os.loadAPI("startup")
if startup.name == "SupHa - Startup Handler by BrunoZockt" then
for k, v in ipairs(startup.getList()) do
if v == programName then
return
end
end
startup.set(programName)
else
os.unloadAPI("startup")
fs.move("startup", "old_startup")
shell.run("pastebin get 19VG8eD6 startup")
os.loadAPI("startup")
startup.set("old_startup", "standart")
startup.set(programName)
end
else
shell.run("pastebin get 19VG8eD6 startup")
os.loadAPI("startup")
startup.set(programName)
end
end
Cheers,
Bruno
PS: For moderators: I wasn't sure if this would fit into the subforum "APIs and Utilitys" since it is an executable program and therefore strictly not an API (I think…). If you think so, feel free to move it there.
Edited on 02 April 2019 - 08:53 PM