Content Templates

New in v1.0.0

Add 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:

VariableDescription
{{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#

PropertyTypeDescription
categorystringType of article: 'milestone', 'news', 'opinion'
tonestringTone: 'celebratory', 'professional', 'critical'
requiredGameStateobjectConditions that must be met for article to appear
weightnumberSelection 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#

PropertyTypeDescription
textstringTweet content with template variables
tonestringTone affects display: 'excited', 'angry', 'neutral'
requiredGameStateobjectConditions 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 requiredGameState values that make sense for the milestone
  • Weight appropriately: Higher weights (8-10) for major milestones, lower (3-5) for flavor content