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

0 favourites
  • 9 posts
From the Asset Store
Fully commented source code/event sheet & sprites to create a space shooter game
  • 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

    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[/code:1cjxvmhp]
    CAN this be done in Construct 2 (some way)
    
    Thanks!
  • 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

    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[/code:wlrul22x]
    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.

  • 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.

  • 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:-)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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.

  • 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<<<

  • 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.

    - 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.

  • 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..

  • 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.

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