-
Notifications
You must be signed in to change notification settings - Fork 22
JS API
Every page loaded in Knossos' web browser has access to a global fs2mod object. This object has the following methods:
-
getVersion(): strReturns fs2mod-py's version
-
isFsoInstalled(): boolReturns true if fs2_open is installed and configured.
-
isFs2PathSet(): boolReturns true if the path to the FS2 directory is set.
-
selectFs2path(): voidPrompts the user to select their FS2 directory.
-
runGogInstaller(): voidLaunches the GOGExtract wizard.
-
getMods(): list of mod objectsReturns a list of all available mods (see the generated section of schema.txt).
-
getInstalledMods(): list of mod objectsReturns a list of all installed mods (see the generated section of schema.txt).
-
getUpdates(): objectReturns a map which follows this syntax: result[mid][local_version] = most_recent_version
-
isInstalled(mid, spec?): boolReturns true if the given mod is installed. The parameters are the same as query()'s.
-
query(mid, spec?): mod objectAllows the web page to query the local mod cache. The first parameter is the mod ID. The second parameter is optional and can specify a version requirement. (i.e.
">=3.0.*")
If no matching mod is found, null is returned. -
fetchModlist(): voidUpdate the local mod cache.
-
addRepo(name, link): voidAdds a new repository.
-
getRepos(): list of [<name>, <link>]Returns a list of all configured repositories.
-
install(mid, spec?, pkgs?): intInstalls the given mod. The first two parameters are the same as query()'s. The third parameter is optional and contains the names of all packages which should be installed (defaults to all required).
Returns -1 if the mod wasn't found, -2 if some of the given packages are missing, 0 if the install failed and 1 on success. -
uninstall(mid, pkgs?): boolUninstalls the given mod. The first parameter is the mod's ID. The second parameter should be used if only some packages should be uninstalled.
Returns true on success. -
runMod(mid): voidLaunch fs2_open with the given mod selected.
-
abortDownload(mid): voidAborts the download for the given mod.
-
showSettings(mid?): voidOpen the settings window for the given mod or fs2_open if no mid is given.
Returns -1 if the mod wasn't found, -2 if the spec is invalid and 1 on success. -
showPackageList(mid, spec?): intOpen a window which allows the user to install and uninstall packages for the given mod.
Returns -1 if the mod wasn't found, -2 if the spec is invalid and 1 on success. -
vercmp(a, b): intCompares two versions
All methods mentioned on this page are implemented in knossos/web.py