AssetUpdates (Mod Updates)

Updated for version ~4.0+.

Module Definition

The module is inherited from ModuleBase. So base parameters can be found there.

The purpose of this module is to provide updating of a mod or a mods assets.

Module name

The name of the module you use as the meta of the module definition is 'AssetUpdates' or 'ModAssetsModule' if _force_search is set to true in the module definition.

XML Structure

<AssetUpdates id provider use_local_dir use_local_path folder_name version_file>
    <custom_provider update_func download_file_func version_api_url download_info_url download_api_url/>
    <folder_name>
        <value_node value/>
        ...
    </folder_name>
    <optional_versions>
        ...
    </optional_versions>
</AssetUpdates>

<AssetUpdates id provider install_directory use_local_dir use_local_path folder_name version version_file important is_standalone>

Example

This example is what you would put inside your main node within your mod config

<AssetUpdates id="16212" provider="modworkshop" version="1.0"/>

Where id is the unique identifier on Modworkshop. So this example will update the directory of the mod with the mod with id '16212' and version being the current version set in the mod page on Modworkshop. You can set it as any string/number you'd like. Numbers are recommended.

The example is what you'll see in most mods. Some old mods may have use_local_path & use_local_dir set to true. These parameters are already set to true by default.

Github Example

For commit based updating:

<AssetUpdates id="Luffyyy/BeardLib-Editor" provider="github" branch="master"/>

The id for github provider updates is owner/repository and branch should be the branch you wish to update from, most of the time this should be master or main.

Upon the next commit, This will create a version_file in the root of your mod with the hash of the commit, you will want to add this to your .gitignore.

For release based updating:

<AssetUpdates id="simon-wh/PAYDAY-2-BeardLib" provider="github" release="true" version="4.4"/>

The version should be the same as the tag of the release.

Optional versions

This example showcases optional versions, which can be enabled in the mod settings in the BeardLib Mod Manager.

The optional versions table should contain AssetUpdates modules with their module name replaced with the name you wish to list in the settings menu. The root element will be the stable version.

<AssetUpdates provider="github" custom_name="GitHub Update" branch="master" id="simon-wh/PAYDAY-2-BeardLib" dont_delete="true">
    <optional_versions>
        <alpha provider="github" branch="testing-alpha" id="simon-wh/PAYDAY-2-BeardLib" />
        <beta provider="github" branch="testing-beta" id="simon-wh/PAYDAY-2-BeardLib" />
        <latest-stable id="14924" version="4.8" provider="modworkshop" important="true" version_is_number="true"/>
    </optional_versions>
</AssetUpdates>

Custom providers

You can either ask the current developers of BeardLib if they can add your site as a provider. Or, use custom providers feature of the module.

To make custom providers you need to have an API in your website. BeardLib will need to communicate with your API to get the version, mod files.

Providers are defined inside the module itself.

Since this is a more complicated topic, we'll start with an XML example:

    <AssetUpdates id="MyMod" version="1.0">
        <custom_provider version_api_url="mycoolwebsite.com/api/check_version/$id$" download_url="mycoolwebsite.com/api/download/$id$"/>
    </AssetUpdates>

<custom_provider check_func download_url/>

In the future a module will be added to add a provider instead of repeating it in the module. Pay attention to the dollar signs in the URL, these will be replaced.

For example, $id$ in this case, will turn into MyMod

Creating a provider class

At the moment, it's possible to create a class for custom providers. The class acts like "custom_provider" only the functions have to be actual functions and not a path to the function. And you can use them like normal providers in the modules themselves.

Example of payday2concepts website (built in BeardLib):

ModAssetsModule._providers.payday2concepts = {}
local pd2c = ModAssetsModule._providers.payday2concepts
pd2c.version_api_url = "http://payday2concepts.net/crimenet/checkversion/$id$.txt"
pd2c.download_url = "http://payday2concepts.net/crimenet/downloads/$id$.zip"
pd2c.version_is_number = true

You'll have to create these early enough so BeardLib mods can use it.

Having more than one update module in the mod.

At the moment, BeardLib adds updates into mods manager as single mod updates and does not account for individual updates. This will be changed in the future.

Functions

Get

Other

Last updated