Which variable is larger?

Get help using Construct 2

Post » Sun Feb 16, 2014 5:56 pm

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?   

B
47
S
15
G
3
Posts: 201
Reputation: 4,625

Post » Sun Feb 16, 2014 6:15 pm

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 161zyblade2014-02-16 18:23:04
B
24
S
9
G
2
Posts: 294
Reputation: 3,160

Post » Sun Feb 16, 2014 6:27 pm

Thanks! The only catch is, there is no randomizing 'tied' votes... is that possible?
B
47
S
15
G
3
Posts: 201
Reputation: 4,625

Post » Sun Feb 16, 2014 6:35 pm

Hm, what do you mean by randomizing "tied votes"?
English is not my mother language, maybe you can rephrase what you've ment?
B
24
S
9
G
2
Posts: 294
Reputation: 3,160

Post » Sun Feb 16, 2014 6:44 pm

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.
B
47
S
15
G
3
Posts: 201
Reputation: 4,625

Post » Sun Feb 16, 2014 7:52 pm

This one should work -> example2.capx
B
24
S
9
G
2
Posts: 294
Reputation: 3,160

Post » Sun Feb 16, 2014 8:14 pm

Oh wow... so simple, but man... complicating at the same time. Makes total sense though; thanks so much. :)
B
47
S
15
G
3
Posts: 201
Reputation: 4,625


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 8 guests