[Plugin] Branch

0 favourites
From the Asset Store
Antisuspend Plugin for Construct 3 prevents the runtime from getting suspended.
  • Branch

    This plugin provides branch like "if", "else if", "else" in condition block.

    See example for more detail.

    Screen shot of example:

    <img src="http://i1081.photobucket.com/albums/j352/rexrainbow1/file.png" border="0">

    Follow these two rules to use branch plugin:

    1. add "if", "else if", "else" at the first condition in condition block.

    2. add "break" at the last condition in condition block. (condition block with "else" can ignore "break")

    I thought C2 will provide branch in the future version. This branch plugin is just a substitute.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Great one..Thanks. I will try soon.

  • and the "or"?

    I'm looking for it ^^

  • Good question!

    The operation of condition block is --

    1. execute from the 1st condition

    2. if 1st condition is true, then execute 2nd condition

    3. if 2nd condition is true, then execute 3rd condition

    4. ... until one condition is false, then this condition block is FALSE

    It's hard to implement "OR" condition at current situation.

  • Dude this is epic. Thanks a stack!

  • Rex: I noticed that when adding the branch plugin, it says at the top "This has only been added to ____ layout", is there a reason that the branch plugin is restricted to a single layout? How come you wouldn't just set the js flags to pf_singleglobal?

    I have a set of if/else commands that appear to fail right after switching layouts despite the fact that the event sheet is common to both.

    Also, this is a great plugin, thanks very much for making it available.

    EDIT: Nevermind, I made a mistake by doing something like this:

    if X

    else if X and A1

    else if Y

    else Z

    The branch seemed to be failing with multiple conditions on the same level. This fixed it:

    if X

    -- sub-event if A1 Do stuff

    else if Y

    else Z

  • cacotigon

    You can add keyboard object, it will display the same message "This has only been added to ____ layout". They are non-world (not shown in layout) plugin.

    In the example at first post, you can see there are two branch objects, each one maintain one layer of branch.

  • Hmm, actually I don't think that is correct. Adding keyboard and/or mouse gives the following message, since they use pf_singleglobal.

    <img src="http://dl.dropbox.com/u/12667027/Construct%202/BranchPlugin/KeyboardAddedMessage.png" border="0" />

    Additionally, if you look through the xml of a project, adding something Function or Branch or SpriteBank plugin all will add to the currently active layout. (I actually had a problem related to this with SpriteBank, I had created a SpriteBank which was located in LayoutB, in LayoutA, tried to serialize layoutA's sprites, then go to LayoutB, and finally return to layoutA and try to deserialize with the SpriteBank, nothing happened as though the SpriteBank instance did not exist, turning on SpriteBank.Global = YES fixed this issue, and prevents SpriteBank from being destroyed).

    For example, my Town_Layout has the following xml:

        <nonworld-instances>

            <instance type="B1" /> // instance of Branch plugin

            <instance type="SpriteBank" /> // instance of SpriteBank

        </nonworld-instances>

    I'm just wondering if there are various unexpected behavior that may occur as a result of something like this. (As I mentioned before, I already encountered an issue with SpriteBank and multiple layouts). I imagine it could kind of be a little tricky for a new user to these plugins, since Branch/SpriteBank/Function aren't actually *placed* on the layout, most users would assume that the plugin would be commonly available to all layouts in their project.

    I probably encounter more of these issues since I make such heavy use of these plugins. :)

  • cacotigon

    Oh, sorry, I pick wrong example. Maybe "Array" object is better.

    I had thinking about using "pf_singleglobal" in these plugins. Since "pf_singleglobal" limits the object number to one, user can not use more then one object.

    User may want use more then one function plugin to avoid name collision or something else.

    SpriteBank has the same issue. User may save instances in different SpriteBank object.

    Yes, it is a little tricky to create global object.

    For setting "Object.Global = YES", I suggest user puts these global objects to the first executed layout.

    Another thing is to notice user that these non-world object is/is not in this layout. I agree that, sometime I will be confused too.

  • Update:

    Add version to 1.0

  • its says 404 at dropbox link

  • I expect rexrainbow created this before C2 had the 'Else' command' but that was a while ago.

    Why would you need this now that C2 provides the same functionality?

    https://www.scirra.com/manual/124/system-conditions

  • rijilks

    zenox98

    Indeed, user did not need this plugin anymore, the official one is better.

  • Kyatric

    Please help me remove the link of this plugin in the index of plugin page.

  • Removed.

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