Skip to main content

Module native

Module native 

Source
Expand description

Sending requests and downloading files on native builds (blocking; run it off the main thread in the game), and writing installed packages to the pack folder.

Enums§

Source
What to install: a file of a mod (Premium), or the file an nxm:// link names.
Step
How far an installation has got, for a progress display.

Constants§

KEY_SETTING
The settings file’s key for the API key (the file is key=value lines).
KEY_VARIABLE
The environment variable that holds an API key; it wins over the settings file.

Functions§

download
Download a file, calling progress(done, total) as it arrives (total when the server says it). Download links need no headers.
install
Write packages into the pack folder (WinData), replacing packages of the same name. Each is written to a temporary file first and then renamed, so a failed write leaves no half-written package.
install_from
Get the download link for source, download it, take out its .pkm packages and write them to dir. Returns the paths written.
key_in_settings
The KEY_SETTING value in a settings file’s text.
send
Send a request and return the body of a 2xx answer. download marks a download-link request, whose 403 means the account needs Premium.
settings_path
The game’s settings file: BANISHED_SETTINGS if set, else settings.txt in the banished-wasm folder of the platform’s configuration folder (as the game reads it).
stored_key
The API key: KEY_VARIABLE, else the KEY_SETTING line of the settings file. An empty value counts as none.