Quick Start (Browser)
Test your first mod in the browser console
The fastest way to start modding is using the browser console. This lets you experiment with the API without creating any files.
Open the Console#
- Start Subway Builder
- Open Developer Tools:
- macOS: `Cmd + Option + I` - Windows/Linux: Ctrl + Shift + I
- Click the "Console" tab
Verify the API#
First, check that the modding API is available:
javascript
console.log(window.SubwayBuilderAPI.version); // "1.0.0"If you see the version number, you're ready to go!
Try Some Commands#
Check Game State#
javascript
// Get current money
const budget = window.SubwayBuilderAPI.gameState.getBudget();
console.log('Current budget:', budget);
// Get all stations
const stations = window.SubwayBuilderAPI.gameState.getStations();
console.log('Stations:', stations.length);
// Get all routes
const routes = window.SubwayBuilderAPI.gameState.getRoutes();
console.log('Routes:', routes);Modify Game State#
javascript
// Give yourself infinite money
window.SubwayBuilderAPI.actions.setMoney(10_000_000_000);
// Pause the game
window.SubwayBuilderAPI.actions.setPause(true);
// Set game speed
window.SubwayBuilderAPI.actions.setSpeed('ultrafast');Add a Custom City#
javascript
window.SubwayBuilderAPI.registerCity({
name: 'Montreal',
code: 'MTL',
population: 4_300_000,
initialViewState: {
zoom: 13.5,
latitude: 45.5017,
longitude: -73.5673,
bearing: 0
}
});After running this, check the city selection screen - you'll see Montreal in the "Modded" tab!
Show a Notification#
javascript
window.SubwayBuilderAPI.ui.showNotification('Hello from my mod!', 'success');Listen for Events#
javascript
// Log every day change
window.SubwayBuilderAPI.hooks.onDayChange((day) => {
console.log(`Day ${day} started!`);
});
// React to station being built
window.SubwayBuilderAPI.hooks.onStationBuilt((station) => {
console.log(`New station: ${station.name}`);
window.SubwayBuilderAPI.ui.showNotification(`${station.name} opened!`, 'success');
});Explore the API#
Use tab completion in the console to explore:
javascript
window.SubwayBuilderAPI. // Press Tab to see all methods
window.SubwayBuilderAPI.gameState. // Press Tab
window.SubwayBuilderAPI.hooks. // Press TabNext Steps#
Once you've experimented in the console, you're ready to create a proper mod file: