How do I 'if-then' (super newb)

Get help using Construct 2

Post » Tue Nov 04, 2014 6:20 am

I am brand new to Construct 2 (been using it since Friday). I'm having a heck of a time getting if-then statements to work. The simple version:

-I'm in a repeat loop that goes to 5.
-Each time through the loop, I am randomly assigning a number between 1 and 15 to the variable 'Pick'.
-I want to assign the contents of 'Pick' to one of 5 text fields. The text fields are labeled B1, B2, B3, B4, B5.
-Each time through the loop, I want to detect what the loop index # is and assign 'Pick' to a specific field. So if the loopindex = 1, I would assign Pick to B1. If loopindex = 2, I would assign Pick to B2, etc...

If I was writing this in other scripting languages, I would write something like this:
if (loopindex == 1) then
B1.text = Pick;
if (loopindex == 2) then
B2.text = Pick;

Basically, an if-then, with no 'else'. But, from what I can tell, the conditional statements in Construct 2 keep forcing me to add an 'else' to it (really frustrated with this). So, when I'm in the loop, I put in an action to set the B1 text to:
loopindex = 1 ? Pick : ""

However, when loopindex doesn't equal 1, it obviously erases what is in B1. How do I not put something after the colon? Is there a 'null' or 'do nothing' command I can put there (couldn't find find one)? :(

Thanks in advance for any help!
Posts: 2
Reputation: 179

Post » Tue Nov 04, 2014 6:42 am

Use the 'else' condition. Construct2 has 'else' condition under 'system'
It will look like this:
if ( loopindex ==1) //do something
else if (loopindex ==2) //do something2
else if... // and so on
Posts: 97
Reputation: 6,614

Post » Tue Nov 04, 2014 6:56 am

simple use subevent like this
You do not have the required permissions to view the files attached to this post.
Posts: 2,010
Reputation: 42,235

Post » Thu Nov 06, 2014 6:34 am

Thank you! Great suggestions. Subevents did it. Thanks!
Posts: 2
Reputation: 179

Return to How do I....?

Who is online

Users browsing this forum: dop2000, Google [Bot], Kyledfrank, newt and 66 guests