Which variable is larger?

  • Sounds easy, but I'm a bit stumped. What I'm doing is sort of like a voting system...

    Say that I have 3 levels, and 3 players... right now I have the following:

    Local Number Level1=0

    Local Number Level2=0

    Local Number Level3=0

    Then it checks to see which player has selected which level, so lets assume that they have selected it like this:

    Local Number Level1=0

    Local Number Level2=2

    Local Number Level3=1

    How would I write an action sequence, that would let me know "Level2 is the greatest"?... and if there is a tie in 'first place', to randomly pick one? Perhaps not using Local Numbers would be an easier ways... thoughts?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • This one might help -> example.capx

    Click on the text objects below to vote, after you voted a few times for each level, click on the text above and get the result.

    edit: made with Construct 2 release 161

  • Thanks! The only catch is, there is no randomizing 'tied' votes... is that possible?

  • Hm, what do you mean by randomizing "tied votes"?

    English is not my mother language, maybe you can rephrase what you've ment?

  • No problem, try doing this in your example:

    Vote once for #1, once for #2, and once for #3.

    Then click "Click me"

    It says "Level 1 voted x1 times"

    Level 2 and Level 3 both have 1 votes too... what I would like, is for it to pick one of the highest voted levels that have the same amount of votes. For example:

    Level 1 has 3 votes

    Level 2 has 3 votes

    Level 3 has 1 votes

    Levels with same amount of votes = 2, LevelPicked=(random (1,2))

    ...perhaps this is impossible. :) Maybe I'll just make this work.

  • This one should work -> example2.capx

  • Oh wow... so simple, but man... complicating at the same time. Makes total sense though; thanks so much. :)

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)