Compare Score in Storyline

Aug 20, 2023

Hello guys, hope to find you all well. I'm creating a multiplayer game with 3 avatars. And my doubt is in calculating the score of first, second and third places. Because I need to compare if one score is higher than the other and so on. I can't think of how to solve this. Can you help me?
I upload my file.
Thanks
3 Replies
Tomas Blazauskas

Hi!

It is possible to do it using Storyline's number comparison, but it would be so much easier to use javascript because there are at least 6 comparisons.  It would be something like this:

player = GetPlayer();
MartaScore = player.GetVar("MartaScoreVariable");
PauloScore = player.GetVar("PauloScoreVariable");
JoanaScore = player.GetVar("JoanaScoreVariable");

If (MartaScore > PauloScore && MartaScore > JoanaScore) {
   player.SetVar("FirstPlaceScore", MartaScore);
   if (PauloScore > JoanaScore) {
      player.SetVar("SecondPlaceScore", PauloScore);      
      player.SetVar("ThirdPlaceScore", JoanaScore);
   } else {
      player.SetVar("SecondPlaceScore", JoanaScore);      
      player.SetVar("ThirdPlaceScore", PauloScore);
   }
}

// Another if with Paulo being first
// And the last if with Joana being first