Content Templates
New in v1.0.0Add custom newspaper articles and social media posts
The content templates API lets you add city-specific newspaper articles and social media posts that appear dynamically based on game state.
Newspaper Templates#
Register custom newspaper headlines that appear based on player progress:
javascript
window.SubwayBuilderAPI.registerNewspaperTemplates([
{
headline: 'Montreal Metro Reaches {{STATIONS}} Stations',
content: 'The STM celebrated today...',
metadata: {
category: 'milestone',
tone: 'celebratory',
requiredGameState: {
minStations: 10
},
weight: 8
}
}
]);Template Variables#
Use these placeholders in your headlines and content:
| Variable | Description |
|---|---|
{{STATIONS}} | Number of stations in the network |
{{ROUTES}} | Number of active routes |
{{CITY}} | Current city name |
{{PASSENGERS}} | Total passengers transported |
{{RIDERSHIP}} | Current ridership per hour |
Metadata Options#
| Property | Type | Description |
|---|---|---|
category | string | Type of article: 'milestone', 'news', 'opinion' |
tone | string | Tone: 'celebratory', 'professional', 'critical' |
requiredGameState | object | Conditions that must be met for article to appear |
weight | number | Selection weight (higher = more likely to appear) |
Required Game State Options#
javascript
requiredGameState: {
minStations: 10, // Minimum stations built
minRoutes: 3, // Minimum routes created
minPassengers: 5000, // Minimum total passengers
minMoney: 1000000, // Minimum cash on hand
}Tweet Templates#
Add social media-style posts that react to player actions:
javascript
window.SubwayBuilderAPI.registerTweetTemplates([
{
text: 'omg {{CITY}} metro is fire π₯',
tone: 'excited',
requiredGameState: {
minPassengers: 1000
}
}
]);Tweet Options#
| Property | Type | Description |
|---|---|---|
text | string | Tweet content with template variables |
tone | string | Tone affects display: 'excited', 'angry', 'neutral' |
requiredGameState | object | Conditions for tweet to appear |
Complete Example#
Here's a full example for a custom city mod:
javascript
const api = window.SubwayBuilderAPI;
// City-specific newspapers
api.registerNewspaperTemplates([
{
headline: 'BVG Announces {{STATIONS}} U-Bahn Stations Operational',
content:
'The Berliner Verkehrsbetriebe celebrated a major milestone today as the U-Bahn network expanded to {{STATIONS}} stations across the city.',
metadata: {
category: 'milestone',
tone: 'professional',
requiredGameState: { minStations: 5 },
weight: 7
}
},
{
headline: 'Transit Riders Demand More Trains',
content: 'Overcrowding concerns prompt calls for expanded service.',
metadata: {
category: 'news',
tone: 'critical',
requiredGameState: { minPassengers: 10000 },
weight: 5
}
}
]);
// Social media reactions
api.registerTweetTemplates([
{
text: 'Just took the new {{CITY}} metro line to work - so much faster! π',
tone: 'excited',
requiredGameState: { minRoutes: 1 }
},
{
text: 'Why is there no station near my apartment yet?? π€ #TransitFail',
tone: 'angry',
requiredGameState: { minStations: 3 }
},
{
text: 'The {{CITY}} transit system just hit {{PASSENGERS}} riders. Wild growth! π',
tone: 'neutral',
requiredGameState: { minPassengers: 5000 }
}
]);Tips#
- Be city-specific: Reference local landmarks, transit authority names, and cultural elements
- Vary the tones: Mix celebratory, critical, and neutral content for realism
- Use realistic thresholds: Set
requiredGameStatevalues that make sense for the milestone - Weight appropriately: Higher weights (8-10) for major milestones, lower (3-5) for flavor content