Vortex API Events

From Nexus Mods Wiki
Revision as of 14:40, 16 June 2020 by Pickysaurus (talk | contribs) (Initial posting)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

This page will document all the events Vortex can send and receive using the Vortex API.

Interacting with events

You can both catch and emit all events inside Vortex. The Vortex API is accessed as a property of the context object.

In order to have your extension respond to an event you can use the following:

context.api.events.on('eventName', callback);

context.api.onAsync('eventName', callback);

To emit an event (or command) yourself use the following:

context.api.events.emit('eventName', callback);

context.api.emitAndAwait('eventName', callback);

Notice that the asynchronous version is called from the API object directly, rather than from the events property.

Events

Mods Enabled

Emitted by Vortex when one or more mods are enabled.

Name mods-enabled
Parameters (mods: string[], enabled: boolean, gameId: string)
Example
context.api.events.on('mods-enabled', 
    (mods, enabled, gameId) => console.log(`${mods.count} mods ${enabled ? 'enabled' : 'disabled'} in ${gameId}`) 
);

Game Mode Activated

Emitted by Vortex when switching the currently managed game, including when the application first starts.

Name gamemode-activated
Parameters (gameId: string)
Example
context.api.events.on('gamemode-activated', 
    (gameId) => console.log(`Activated game mode in ${gameId}`) 
);
Notes
  • The gameId property can be undefined. This usually happens when the user deletes their last profile for an active game.

Startup

Emitted by Vortex when the application first starts.

Name startup
Parameters none
Example
context.api.events.on('startup', 
    () => console.log('Vortex is starting up.') 
);

Will Deploy

Emitted asynchronously by Vortex before starting a deployment.

Name will-deploy
Parameters (profileId: string, oldDeployment: { [modType: string]: IDeployedFile[] })
Example
context.api.onAsync('will-deploy', 
    (profiled, oldDeployment) => console.log(`About to deploy mods for profile ${profileId}`) 
);

context.api.emitAndAwait('will-deploy', profileId, lastDeployment);


Commands

Internal Events