tm.version
Update check for a Twilight Moon resource. On start it compares the installed version with the published versions file and logs whether the install is current, outdated or below the oldest safe release. Server only.
tm.version.check() -- this resource, version read from its fxmanifest
tm.version.check('tm_garages', '1.2.0') -- a named entry and an explicit installed version
tm.version.compare('1.10.0', '1.9.2') --> 1| Function | Notes |
|---|---|
check(resource?, current?) | Fetches the versions file once per resource and logs the result. resource is the entry name (default the calling resource) and current the installed version (default the manifest version). |
compare(a, b) | 1 when a is newer, 0 when equal, -1 when older, nil when either side is not a version. Compares number by number, so 1.10.0 is newer than 1.9.2. A suffix after the patch number (1.2.0-beta) is ignored. |
The versions file
The file is JSON and is never run as code. Every released resource has one entry:
{
"tm_lib": { "version": "0.4.0", "security": "0.4.0" },
"tm_garages": { "version": "1.2.0", "security": "1.0.0" }
}versionis the newest release. An install below it logs a warning.securityis the oldest release with no known security problem. An install below it logs an error.- An install ahead of
versionlogs an info line (a development build).
The source of truth is versions/twilightmoon.json in the versions repo. Add an entry when a resource is created and update it when a release is cut. A resource with no entry stays quiet.
Output
The notices are developer console lines, so they stay English. A server that cannot reach the file, or a resource that is not listed yet, logs at debug level only, so a server without internet access is not spammed.
Turning it off
These are bootstrap convars (see tm_lib/tm.cfg), not settings:
set tm:versionCheck 0
set tm:versionsUrl "https://example.com/twilightmoon.json"Using it in a new resource
The boilerplate templates already call tm.version.check() in modules/server.lua. For a resource that was not scaffolded, call it once from the server start handler.