Repository navigation
Example 12 show module and card art
github-actions[bot] edited this page Nov 21, 2026
·
1 revision
Generated from the thetowersdk repository. Edits made here are overwritten on the next push — change the source file instead.
/**
* Pointing at artwork you supply yourself.
*
* pnpm exec tsx examples/12-show-module-and-card-art.ts
*
* This package ships **no images and no catalogue of them**. The art belongs to TechTree Games,
* there is no permission to redistribute it, and a list naming every sprite in the game is derived
* from the game whoever typed it — so that is withheld too.
*
* What ships is the naming rule, so a tool can find a file in a directory of artwork you already
* have. This example runs with no artwork present at all, because building a path and loading a
* file are different steps: it prints where each file WOULD be.
*/
import { gameAssetPath, gameAssetPaths, assetSlug, towerAssetUrl } from '@beardedunicorn/thetowersdk/assets'
import { CARD_TEMPLATES, MODULE_TEMPLATES } from '@beardedunicorn/thetowersdk/data'
/** Wherever you serve your own extraction from. */
const ART_ROOT = '/art'
console.log('Modules')
for (const module of MODULE_TEMPLATES.slice(0, 5)) {
const path = gameAssetPath(module.name, { domain: 'modules' })
console.log(` ${module.name.padEnd(22)} ${towerAssetUrl(path, ART_ROOT)}`)
}
console.log('\nCards')
for (const card of CARD_TEMPLATES.slice(0, 5)) {
const path = gameAssetPath(card.name, { domain: 'cards' })
console.log(` ${card.name.padEnd(22)} ${towerAssetUrl(path, ART_ROOT)}`)
}
/*
* Every size at once, for a `srcset`. Nothing requires you to have all three — use the subset
* your extraction produced and ignore the rest.
*/
console.log('\nOne module at every size')
const sizes = gameAssetPaths('Om Chip', { domain: 'modules' })
for (const [size, path] of Object.entries(sizes ?? {})) {
console.log(` ${size} ${path}`)
}
/*
* Name your own files with `assetSlug` rather than reimplementing the rule. Two implementations
* of one convention is how a name silently stops matching its file — and a missing image does not
* throw, it renders as a gap on one card, at one size, which nobody notices for months.
*/
console.log('\nThe slug rule')
for (const name of ['Om Chip', 'Amplifying Strike', 'Damage / Meter']) {
console.log(` ${name.padEnd(22)} -> ${assetSlug(name)}`)
}
/*
* A name that slugifies to nothing returns null rather than `modules/-md.webp`, which would look
* like a real path and resolve to nothing.
*/
console.log('\nRefusals')
console.log(' empty name ->', gameAssetPath(' ', { domain: 'modules' }))
console.log(' no domain ->', gameAssetPath('Om Chip', { domain: '' }))Generated from TheTowerSDK — do not edit here. Docs and live demos: https://beardedunicorn.github.io/TheTowerSDK/
- Workshop
- Workshop Enhancements
- Labs
- Cards
- Modules
- Module Rarities and Merging
- Module Substats
- Module Upgrade Costs
- Ultimate Weapons
- Ultimate Weapon Plus
- Bots
- Guardian
- Relics
- Themes
- Tiers
- Battle Conditions
- Enemies
- Perks
- Tournaments
- Milestones
- The Vault
- Daily Missions
- Guild
- Currencies
- Reference Tables
- Glossary
- Irreversible Upgrades
- Game Patch Notes
- Game Version History
SDK
- Quick Start
- Entry Points
- How It Fits Together
- Getting an Official Game Export
- Reading a Save
- Reading The Community Wiki
- Game 29.1 Data
- Formulas
- Builders
- Charts
- Effective Paths
- Examples
- Templates
- Building a Bot On This
- Google Sheets
- Desktop and Mobile
- Optional Add-ons
- Using It With An AI Agent
- Using Your Own Artwork
- Names And Acronyms
- Patch Notes
- Accuracy
- Versioning
- Where the Docs Live
- Contributing
- Credits
- License
Guides
Examples
- 01-browse-game-data.ts
- 02-read-a-save-file.ts
- 03-plan-upgrades-from-a-save.ts
- 04-generate-a-chart.ts
- 05-generate-a-cost-table.ts
- 06-read-the-community-wiki.ts
- 07-format-like-the-game.ts
- 08-build-a-calculator.ts
- 09-build-a-bot.ts
- 10-read-a-sheet.ts
- 11-build-a-knowledge-base.ts
- 12-show-module-and-card-art.ts
Templates