This Lua module lets your Tabletop Simulator object auto-update its script directly from a GitHub repository.
- Automatically checks GitHub for new versions
- Compares semantic versions (
1.2.3style) - Fetches and replaces the script when an update is found
- Reloads the object automatically
- Provides a useful base class for your script
- Optionally updates custom objects
- Optional pre-commit hook to prevent infinite update loops
Your GitHub repo should contain at least two files:
yourscript.lua# Your actual TTS scriptyourscript.ver# A text file with the current version number (e.g.1.0.0)
- Copy the
BaseandAutoUpdateclasses into the top of your script. - Configure these values:
local Base = {
name = "Your Script Name", -- used for output of messages
...
}
local AutoUpdate = {
version = "1.0.0", -- current version of your script, must match the .ver file contents
versionUrl = "https://raw.githubusercontent.com/yourname/yourrepo/refs/heads/main/yourscript.ver", -- text file with the version number, eg: 1.0.0
scriptUrl = "https://raw.githubusercontent.com/yourname/yourrepo/refs/heads/main/yourscript.lua", -- latest version of your script
...
}- Add a one-liner to your object’s onLoad:
function onLoad()
AutoUpdate:run()
endIf you want the script to update custom object, you can use the AutoUpdateCustomObject module.
- Copy the
AutoUpdateCustomObjectclass into the top of your script (belowAutoUpdate). - Configure
customObjectwith the required values (see Custom Game Objects):
local AutoUpdateCustomObject = {
customObject = {
image = "https://steamusercontent-a.akamaihd.net/ugc/ABC123/",
image_secondary = "https://steamusercontent-a.akamaihd.net/ugc/ABC456/",
},
...
}- Add a one-liner to your object’s onLoad:
function onLoad()
AutoUpdateCustomObject:run()
endWhen you want to release an update:
- Update your script file (
yourscript.lua). - Update the version file (
yourscript.ver) with the new version string, e.g.:1.0.1. - Commit and push to GitHub.
- Next time the object is loaded in Tabletop Simulator, it will auto-update.
Versions must be numeric (semantic versioning is recommended, e.g. 1.0.0).
Works best if each script has its own .lua and .ver file pair in the repo.
If the version in your .lua file is less than the version in your .ver file, you will cause an infinite update loop.
To prevent this, set up a pre-commit hook that checks the versions match before allowing a commit.
- Save the
git_hooks_pre-commitfile below as.git/hooks/pre-commit. - Make it executable (this step is for Mac/Linux only, Windows users can skip it)
chmod +x .git/hooks/pre-commit. - Test it:
python3 .git/hooks/pre-commit.
Now your commit will fail if the .lua and .ver versions don't match.
MIT License. Free to use and adapt.
Very nice! Could be worth handling non-200 responses in
fetchNewScriptas well but this looks very comprehensive.