overwolf.extensions.current API
Notify you when something interesting happens while playing a particular game.
The full list of supported games with their Game ID’s is always up to date and can be found here.
Please read all the info about how to use game events in your app in our using game events guide.
This API enables you to get real-time game events (kill, death, etc.) for specific games that are defined in your app's manifest, under the "game_events" section.
Regardless, you have the overwolf.games API that gives you general "game info" events about the currently running game's state (process name, focus, command line info, and more).
Methods Reference
Events Reference
- overwolf.games.events.onError
- overwolf.games.events.onInfoUpdates2
- overwolf.games.events.onNewEvents
Types Reference
- overwolf.games.events.SetRequiredFeaturesResult Object
- overwolf.games.events.GetInfoResult Object
- overwolf.windows.ErrorEvent Object
- overwolf.windows.InfoUpdates2Event Object
- overwolf.windows.NewGameEvents Object
- overwolf.windows.GameEvent Object
Sample App
You can find an example of overwolf.games.events API usage here. This one notifies whenever a relevant event has happened in League of Legends.
setRequiredFeatures(features, callback)
Version added: 0.93
Sets the required features from the provider.
Parameter | Type | Description |
---|---|---|
features | string[] | String array of features to utilize |
callback | (Result:SetRequiredFeaturesResult) => void | all available features for the registered games declared in the manifest |
Usage Example
Example for setting League of Legends required features:
var g_interestedInFeatures = [
'summoner_info',
'gameMode',
'teams',
'matchState',
'kill'
];
overwolf.games.events.setRequiredFeatures(g_interestedInFeatures, function(info) {
if (info.success == false)
{
console.log("Could not set required features: " + info.error);
return;
}
}
- it's important to wait for the success status to ensure that required features will be registered and trigger events properly.
- If your app uses a background controller, make sure to call the setRequiredFeatures function only from your background controller.
Example for setting required features and waiting for 'success':
async setRequiredFeatures() {
let tries = 1;
let result;
while ( tries <= MAX_RETRIES ) {
result = await new Promise(resolve => {
overwolf.games.events.setRequiredFeatures(FEATURES_ARRAY, resolve);
})
if ( result.success === true ) {
// make sure our required features were registered
return (result.supportedFeatures.length > 0);
}
// wait 3 sec before retry
await new Promise(resolve => {
setTimeout(resolve, 3000);
});
tries++;
}
console.warn('setRequiredFeatures(): failure after '+ tries +' tries'+ JSON.stringify(result, null, 2));
return false;
}
getInfo(callback)
Version added: 0.95
Gets the current game info.
Parameter | Type | Description |
---|---|---|
callback | (Result:GetInfoResult) => void | Provides the current game info |
Usage Example
overwolf.games.events.getInfo(function(info) {
console.log(info);
});
onError
Version added: 0.78
Fired when an error occurred in the Game Event system, with the following structure: ErrorEvent Object.
onInfoUpdates2
Version added: 0.96
Fired when there are game info updates with a JSON object of the updates, in the following structure: InfoUpdates2Event Object
Our best practice is removing event listeners and then adding the listener back to prevent accidental multiple listeners.
Usage Example
overwolf.games.events.onInfoUpdates2.addListener(function(info) {
console.log("Info UPDATE: " + JSON.stringify(info));
});
onNewEvents
Version added: 0.96
Fired when there are new game events with a JSON object of events information, in the following structure: NewGameEvents Object
Our best practice is removing event listeners and then adding the listener back to prevent accidental multiple listeners.
Usage Example
overwolf.games.events.onNewEvents.addListener(function(info) {
console.log('EVENT FIRED: ' + JSON.stringify(info));
});
SetRequiredFeaturesResult Object
Parameter | Type | Description |
---|---|---|
success | boolean | |
error | string | null if success is true |
supportedFeatures | string[] | all available features for the registered games declared in the manifest |
Example data: Success
{
"success":true,
"supportedFeatures":[
"summoner_info",
"teams",
"kill"
]
}
GetInfoResult Object
Parameter | Type | Description |
---|---|---|
success | boolean | |
error | string | null if success is true |
res | object | Provides the current game info |
Example data: Success
The current game's info, registered features, and all available info for the current game session.
{
"success":true,
"res":{
"summoner_info":{
"id":"79489298",
"name":"itaygl",
"region":"EUW",
"champion":"Rengar"
},
"game_info":{
"match_started":"True",
"matchStarted":"True",
"teams":"%5B%7B%22team%22:%22100%22,%22champion%22:%22Rengar%22",
"gameMode":"custom",
"game_mode":"custom",
"minionKills":"5",
"minions_kills":"5",
"gold":"1002"
},
"features":{
"kill":"True",
"assist":"True",
"minions":"True",
"deathAndRespawn":"True",
"death":"True",
"minion":"True",
"gold":"True",
"level":"True",
"abilities":"True",
"gameMode":"True",
"game_mode":"True"
},
"level":{
"level":"3"
}
}
}
ErrorEvent Object
Parameter | Type | Description | Notes |
---|---|---|---|
reason | string | the error reason |
Event data example: Success
{
"reason": "some reason",
}
InfoUpdates2Event Object
Parameter | Type | Description | Notes |
---|---|---|---|
info | string | ||
feature | string |
Event data example: Success
{
"info":{
"game_info":{
"minionKills":"3"
}
},
"feature":"minions"
}
NewGameEvents Object
Parameter | Type | Description | Notes |
---|---|---|---|
events | GameEvent[] array |
Event data example: Success
{
"events": [
{
"name": "death",
"data": "{`count`: `2`}"
}
]
}
GameEvent Object
Parameter | Type | Description | Notes |
---|---|---|---|
name | string | ||
data | string |
Event data example: Success
{
"name": "death",
"data": "{`count`: `2`}"
}