ELSE Statements

This forum is currently in read-only mode.
  • Hello again!

    I have been working on a menu function using a number of buttons, and have run into the problem of simultaneous executions from a single button press. After reading through the forums, there have been several mentions of using the ELSE function to fix this. However, I cannot seem to get it to work. Are there any examples of the else function in action that are available to check out?

    Thanks!

  • You must put "ELSE" as a different Event.

    For example, if you want to accomplish something like this:

    if ( MyObject('myVariable') == 12)

    DoSomething;

    else

    DoAnotherThing;

    You have to prepare such events:

    Event #1:

    Conditions: MyObject('myVariable') is equal to 12

    Actions: DoSomething

    Event #2 (right below Event #1)

    Conditions: ELSE

    Action: DoAnotherThing

    When you use "OR" then OR is just withing the same event. But when you are using "ELSE", this "ELSE" must be a seperate event. What is more, this "ELSE" event must be put right below event you want to have else-d. You'll notice a line connecting Event #1 and "ELSE Event" - this line shows which event the "ELSE Event" is referencing to.

  • i prefer to use ELSE in a sub-event

  • i prefer to use ELSE in a sub-event

    Does that work?? We only coded it to work for following events...

  • > i prefer to use ELSE in a sub-event

    >

    Does that work?? We only coded it to work for following events...

    It worked some builds ago...

  • > i prefer to use ELSE in a sub-event

    >

    Does that work?? We only coded it to work for following events...

    i believe so...

    like

    on click

    --condition 1 -- do something

    --else -- do something else

  • >

    > > i prefer to use ELSE in a sub-event

    > >

    > Does that work?? We only coded it to work for following events...

    >

    i believe so...

    like

    on click

    --condition 1 -- do something

    --else -- do something else

    It's following a sub-event, it's not just a sub-event.

    That's why it works.

  • Oh right, yeah. I thought you meant:

    + Condition

    ----> ELSE ...

    It works fine via subevents like you say.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • AH!!

    Thank you! That fixed it.

  • Ok. I thought I had it, but no luck. Ive uploaded the .cap if some one wants to take a look at and tell me where I am messing up, that would be helpful.

    http://www.2shared.com/file/4137951/cb2d75a4/Core.html

  • The way you have it now, the ELSE statement is completely bypassing the sub events, so it's working like this:

    -If global variable "Menu State" is "Main"

    + Do nothing

    -Else

    + Set global variable "Menu State" to "Main"

    So you are always setting "Menu State" to "Main".

  • Thanks a bunch. Got that fixed (by simply deleting the ELSE), but the single player menu still refuses to execute (I believe that the single player menu return is initiating the moment I press the single player execute button). Is there a way to fix this in its current format, or should I be using a different base structure altogether?

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