How do I create multiple conditions? ("if -Then if")

Just started using Construct 2? Post your questions here

Post » Thu Nov 19, 2015 6:14 pm

Greetings fellow gamemakers

My first post, so please bear with me.

I'm new at this way of making games. I have always been a "die hard" Basic coder, but I see the great possibilities in Construct 2 to get things going quickly.

In Basic I can create multiple conditions for an event. "If condition is true, then if another condition is true, then do this, (else do that)". It looks like I can only make one condition and then the action In "Construct 2". I really need to make more. I have looked in tutorials/Manual/Forum, but no luch yet.

Please have a look at this crude (Basic) example snippet herunder

Code: Select all
If Enemy_Is_On_Screen=1 Then

If EnemyAction=1 Then Print "Run"
If EnemyAction=2 Then Print "Walk"
If EnemyAction=3 Then Print "Stop"

EndIf

CAN this be done in Construct 2 (some way)

Thanks!
B
20
S
5
G
1
Posts: 23
Reputation: 1,715

Post » Thu Nov 19, 2015 6:29 pm

Colorfish wrote:Greetings fellow gamemakers

My first post, so please bear with me.

I'm new at this way of making games. I have always been a "die hard" Basic coder, but I see the great possibilities in Construct 2 to get things going quickly.

In Basic I can create multiple conditions for an event. "If condition is true, then if another condition is true, then do this, (else do that)". It looks like I can only make one condition and then the action In "Construct 2". I really need to make more. I have looked in tutorials/Manual/Forum, but no luch yet.

Please have a look at this crude (Basic) example snippet herunder

Code: Select all
If Enemy_Is_On_Screen=1 Then

If EnemyAction=1 Then Print "Run"
If EnemyAction=2 Then Print "Walk"
If EnemyAction=3 Then Print "Stop"

EndIf

CAN this be done in Construct 2 (some way)

Thanks!


This can obviously be done, but using C2s Event System takes a little getting used to.

I'd recommend the following sections of the manual: Events, and especially the link to How Events Work.

That should get you up and running in no time.

If you still have a problem after that, feel free to post whatever questions you may have and we'll try to help.
If your vision so exceeds your ability, then look to something closer.
Moderator
B
134
S
30
G
84
Posts: 5,386
Reputation: 58,454

Post » Thu Nov 19, 2015 6:34 pm

Hi there Colorfish,

It is indeed possible, the "event" part of the event sheet is effectively an If statement. I'd look at multiple conditions and sub-events to get a deeper understanding.
B
59
S
21
G
9
Posts: 641
Reputation: 9,787

Post » Fri Nov 20, 2015 5:18 am

Thank you guys, for the swift reply.

I have yet only glanced the manuel and I feel a bit lazy asking for help already, but I wanted to make sure that the basic condition/programming stuff was there, in the system before "converting" to Construct 2. And it's looking very promising:-)
B
20
S
5
G
1
Posts: 23
Reputation: 1,715

Post » Fri Nov 20, 2015 5:33 am

just one to note watch your group event if you ever do because just an hour ago I almost lost my wits when My code wasnt working at all just to find out i accidently place a Group under a onstart condition ....so be careful when using groups.
B
52
S
24
G
6
Posts: 391
Reputation: 7,845

Post » Fri Nov 20, 2015 7:49 am

use the Function plugin
checking YouTube a guy do some video on it think it name 10 minutes with construct two... awesome
eg
system - on start layout - function call PlayerInMotion

function on PlayerInMotion - (put the Run, Walk, Stop, Action here)

to say print Run just use a text object under the run action to display the word RUN hope this help...
i can do a video to show you if do understand..




>>>i am still asking scirra for a discount on a personal lic<<<
B
9
S
2
Posts: 66
Reputation: 717

Post » Fri Nov 20, 2015 12:55 pm

@Gearworkdragon Thanks for the heads-up, I know I must be carefull organizing and moving/copying elements, I'm sure I will have my share of pulling hair and wits loosing in the future.

@hotheadI - love Functions, and I'm thrilled that I can use it in C2. The snippet was just for demo purposes to make my point clear.
B
20
S
5
G
1
Posts: 23
Reputation: 1,715

Post » Fri Nov 20, 2015 12:59 pm

Colorfish wrote:Thank you guys, for the swift reply.

I have yet only glanced the manuel and I feel a bit lazy asking for help already, but I wanted to make sure that the basic condition/programming stuff was there, in the system before "converting" to Construct 2. And it's looking very promising:-)


If it's basic, you can do it with construct2 in a very easy way
If it's more complicated, you can do it with construct in an easy way
If it's very hard, you can do it with construct..

What I've noticed on this forum is that people coming from other programming background overcomplicate things more often and are amazed at how some things can be done in such an easy way..
Ofcourse things are always complicated if you don't know how and when you are used to a certain way, it's sometimes hard to learn another, but Construct2 is fully packed and has a great community to go to if you can't find the solution you need..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Fri Nov 20, 2015 1:08 pm

You are right of course, I already found elements, functions and actions that makes my life so much easier. I'm just getting my head around C2 and I sure that it will be a long at happy relationship. And I rest easy knowing the excellent help on this forum.
B
20
S
5
G
1
Posts: 23
Reputation: 1,715


Return to Beginner's Questions

Who is online

Users browsing this forum: MPPlantOfficial and 2 guests