altf4pressthem

Launching an app when specific event happens (L.O.L)

Recommended Posts

Hello everyone! First time developer here and I have a question on when my window shows up for League of Legends. Looking at the sample app i see that there is a launch_events option and event name in the manifest.json

"game_events": [5426],
"launch_events": [
  {
    "event": "GameLaunch",
    "event_data": {
    "game_ids": [5426]
  },
"start_minimized": false
  }
]

,I want the window for my app to appear when the match ends in league of legends (like a window saying "good job" or "better luck next time" for example) and i see that there is a matchState option in events. I changed it to this but nothing seems to be happening 

    "launch_events": [
      {
        "event": "matchEnd",
        "event_data": {
          "game_ids": [
            5426
          ]
        },
        "start_minimized": false
        }]

 

Am I using the terms incorrectly? Any help would be appreciated. Thank you!

Edited by Colorfulstan
formatting

Share this post


Link to post
Share on other sites

Hello altf4pressthem, welcome to the Dev forums.

 

You will need to use an event listener.

So for your example:

overwolf.games.events.onNewEvents.addListener(function (info) {
	console.log("New event:");
    console.log(info);
	// parse / deal with info and check if the event is matchEnd and launch a new window here
});

 

 

 

Share this post


Link to post
Share on other sites

Ah thank you both so much for answering! Yes i was genuinely confused on the launch event. 

 

Reading around, with the event listener, is it possible to launch at match end or should i launch the app with GameLaunch and make the window appear with event listener with matchEnd?

 

Thank you so much for your help! i was going around in circles yesterday!

 

(P.S: matchEnd should work with bot games correct? i don't know how to test the app without actually playing a game and i don't really want to have to play a full match just for testing)

Share this post


Link to post
Share on other sites

Yes I believe the only way to achieve what you're intending is to launch a 'ghost' window on game launch, add the game event listener, check the id & watch for matchEnd then launch your window.

Also I believe there is a game mode property that I know will say classic, not sure if it says bot game or not but if you want to filter on that as well you can.

Share this post


Link to post
Share on other sites

never used the "match_end" event so far, im using the onGameStateChanged eventlistener to check if the league game-window gets closed, which indicates that it returns to the desktop-client. If you don't neccessarily need the actual endpoint of the match but it's enough to know when the game closes that is sufficient in most use cases i think.

You then can easily test by starting a game in tutorial-mode and just close it after it starts with alt+f4. By far the fastest way to manually test the general startup / teardown of an app afaik.

Here is a snippet to catch that game-closing event

overwolf.games.onGameInfoUpdated.addListener(function (result: ODKGameInfoChangeData) {
            var changeData   = result;
            var gamefinished = changeData.gameInfo !== null &&
                changeData.gameInfo.title === 'League of Legends' &&
                changeData.runningChanged; // runningchanged indicates that Game just finished
            if (gamefinished) {
                // do stuff 
            }
        });

 

Share this post


Link to post
Share on other sites

I see, thank you all very much for the help. @Colorfulstan I will definitely use this for testing purposes and while the window popping up at the desktop client makes sense, I would like to try having the window pop up at defeat or victory. 

 

I did try something when I had free time last night and would like opinions on this. I searched the forums and found an eventListener and it technically worked. I launched the app at game launch with the window minimized and had this piece of code (mainly plugged in from LOL sample app) 

 

  // an event triggerd
  overwolf.games.events.onNewEvents.addListener(function (info) {
      for (var i in info.events) {
          if (info.events.name == 'matchStart') {
        overwolf.windows.restore('MainWindow')
          }
      }

 

The window did pop up at the beginning of the match but when I tried replacing matchStart with matchEnd (played a bot game for fun last night), nothing came when the match ended. 

 

Again thank you all for the great help. This is definitely making me enjoy developing apps :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now