Modding:Modder Guide/APIs/Update checks

From Stardew Valley Wiki
< Modding:Modder Guide‎ | APIs
Revision as of 03:21, 24 May 2020 by Pathoschild (talk | contribs) (create page)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Creating SMAPI mods SMAPI mascot.png


Modding:Index

Every SMAPI mod or content pack can benefit from automatic update checks, so the player sees an alert when a new version is available. This helps ensures players always have the latest version of your mod, which improves their experience and reduces support requests.

Introduction

Enable update checks

You can add update keys to your manifest.json to enable update checks. An update key tells SMAPI where the mod page is. For example, Nexus:2400 means mod ID 2400 on Nexus:

"UpdateKeys": [ "Nexus:2400" ]

If you have multiple update keys, SMAPI will check them all and show an alert for the latest version it finds. (If multiple sites have the latest version, it will link to the earlier one in the list.)

"UpdateKeys": [ "Chucklefish:4250", "Nexus:541", "GitHub:Pathoschild/LookupAnything" ]

(SMAPI also fetches mod info from the mod compatibility list, so mods on that page may get update checks even without update keys. You should still add update keys to your manifest in case that changes, and to support mod managers and other tools.)

Valid sites

Here are the supported mod sites:

mod site description
Chucklefish Make sure you have a mod release page (with a URL containing /resources/ instead of /thread/) and it has a semantic version, then specify the mod ID (the number in the mod page URL).
"UpdateKeys": [ "Chucklefish:4250" ]
CurseForge Make sure the latest file's display name contains a semantic version at the end, with a space before the version and optional file extension. For example, SMAPI will recognise the version in these display names: 1.3.0, Example Mod 1.10, Example Mod 1.10.0-prerelease.zip.
"UpdateKeys": [ "CurseForge:309243" ]
GitHub Make sure your GitHub project has at least one release and the latest release's tag is a semantic version, then specify your GitHub username and project name.
"UpdateKeys": [ "GitHub:Pathoschild/LookupAnything" ]
SMAPI will get the version from the release tag.
ModDrop Make sure the mod page has a semantic version, then specify the mod ID (the number in the mod page URL).
"UpdateKeys": [ "ModDrop:123338" ]
SMAPI will get the version from files under 'Main Versions'.
Nexus Mods Make sure the Nexus mod has a semantic version, then specify the mod ID (the number in the mod page URL). When creating a new mod on Nexus, the ID is added to the URL after the first step, before you need to upload the file.
"UpdateKeys": [ "Nexus:541" ]
SMAPI will get the version from the mod, 'main files' downloads, or 'optional files' downloads (whichever is higher).

Advanced

Beta versions

A prerelease version (often called an alpha or beta) has a prerelease tag in the version number. For example, 1.0.0-beta.5 is a prerelease version of an upcoming 1.0.0.

If you have both prerelease and non-prerelease versions, update checks depend on player's installed mod version:

  • Stable channel: players with a non-prerelease version installed only see update alerts for non-prerelease versions (unless the main mod version is prerelease).
  • Beta channel: players with a prerelease version see update alerts for any newer version, whether prerelease or non-prerelease.

For example, let's say your mod has two versions available: 1.7.0 and 2.0.0-beta. A player who has 1.6.0 installed would see an update alert for 1.7.0, and a player with 1.6.1-beta would see an update alert for 2.0.0-beta.

Disable update checks locally

SMAPI checks for updates in the background, so disabling update checks has zero effect on load times.

To disable update checks...

  • For SMAPI and all mods: edit the smapi-internal/config.json file and set CheckForUpdates to false. You'll no longer be notified about newer versions of SMAPI or installed mods, so this is not recommended.
  • For a specific mod: edit the smapi-internal/config.json file and add the mod ID to the SuppressUpdateChecks field.

Note that edits to smapi-internal/config.json will be lost when you update SMAPI. See the instructions at the top of that file to create a permanent config file.