# How do I Doing something like select case??

Get help using Construct 2

### » Sun Dec 21, 2014 11:15 am

i need to do something like select case or more than 2-3 if.
How can I do it?

I need to create a random number between 1-5 and if that 1 then do something if it 2 do something else and so on

PS
It's not about the question but Congratulations to myself I bought a license
B
13
S
2
Posts: 95
Reputation: 861

### » Sun Dec 21, 2014 12:01 pm

I'd say for 5 values just do if-elses. However I think there is a 3rd party plugin for switch/case structure, if you're desperate.
Well done buying a licence. Are you doing mobile or pc games?
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

### » Sun Dec 21, 2014 1:48 pm

codah wrote:I'd say for 5 values just do if-elses. However I think there is a 3rd party plugin for switch/case structure, if you're desperate.
Well done buying a licence. Are you doing mobile or pc games?

i do pc game for web can you give me an example of if-elses because I did not understand how to do it (I am new to this software)
B
13
S
2
Posts: 95
Reputation: 861

### » Sun Dec 21, 2014 9:11 pm

You better read the manual and just play with some code. Also most if not all the official sample projects will have if-else (although, there's no actual 'If' but there is an 'Else')

e.g:

Sprite: myVar1 = 1 -> <do something 1>
Else
Sprite: myVar1 = 2 -> <do something 2>
Else
Sprite: myVar1 = 3 -> <do something 3>
etc.
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

### » Tue Oct 20, 2015 7:31 pm

@codah ,@maordany ,
I am facing a similar case where there are 7 outcomes based on the values of a numeric variable.
Question When I try using if else- do I add the second and subsequent conditions by first adding an else block and then editing that condition into a comparison ? or do I ad the second comparison as a sib event to the else ?
In any case I am not able to add the else for the third condition.. Any help ?
I tried using a plugin developed by @wastrel but it doesn't show up even after being added to the plugins folder.
B
6
Posts: 16
Reputation: 296

### » Fri Dec 11, 2015 9:43 pm

@UpendraWatwe, i have updated the plugin and example links on the SwitchCase Plugin topic. Let me know if you can't get it to work.
Don't see the fnords and they won't eat you!
B
80
S
18
G
12
Posts: 326
Reputation: 11,986

Thanks @Wastrel
B
6
Posts: 16
Reputation: 296