context object provides core functionality for OpenRCT2 plugins, including access to storage, game actions, event subscriptions, and utility functions.
Properties
The current version of the plugin API. This integer increments by 1 with each API change.
The user’s current configuration settings.
Shared generic storage for all plugins. Data persists across OpenRCT2 instances and is stored as a single JSON file in the OpenRCT2 user directory.
Objects and arrays are only copied by reference. The external file is only written when using the
set method.The current game mode/screen. Can be:
"normal"- Regular gameplay"title"- Title screen"scenario_editor"- Scenario editor"track_designer"- Track designer"track_manager"- Track manager
Whether the game is currently paused. Readonly in network mode.
Storage Methods
getParkStorage()
Gets the storage for the current plugin or a specified plugin. Data is persisted within the .park file.The name of the plugin to get storage for. If undefined, uses the current plugin’s name. Plugin names are case sensitive.
All data is serialized every time the park is saved, including automatic saves. Keep storage data minimal for performance.
Rendering Methods
captureImage()
Renders the current map state and saves to disk. Useful for server administration and timelapse creation.Options controlling the capture and output file.
Utility Methods
getRandom()
Generates a random integer using the game’s pseudo-random number generator. This is part of the game state and shared across all clients.The minimum value (inclusive).
The maximum value (exclusive).
formatString()
Formats a string using OpenRCT2’s formatting codes and arguments.The format string (e.g., “Guests: ”)
Arguments to insert into the string.
getIcon()
Gets the image number for a given icon name.The name of the icon.
Game Actions
registerAction()
Registers a custom game action that allows clients to interact with the game.The unique name of the action.
Logic for validating and returning a price for an action.
Logic for validating and executing the action.
queryAction()
Queries the result of running a game action without executing it.The name of the action.
The action parameters.
Function called with the result.
executeAction()
Executes a game action. In multiplayer, this sends a request to the server.The name of the action.
The action parameters.
Function called with the result.
Event Subscription
subscribe()
Subscribes to game events. Returns anIDisposable that can be used to unsubscribe.
The event type to subscribe to.
Function to call when the event occurs.
- Interval Events
- Map Events
- Network Events
- Action Events
Timers
setInterval()
Registers a function to be called repeatedly at a specified interval.The function to call.
The delay in milliseconds between calls.
setTimeout()
Registers a function to be called once after a specified delay.The function to call.
The delay in milliseconds.
Track Segments
getTrackSegment()
Gets track segment information for a given type.The track segment type.

