[Plugin] Branch

Post your completed addons to share with the community

Post » Sun Oct 30, 2011 1:59 am

Branch

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

See example for more detail.

Screen shot of example:


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.rexrainbow2013-02-12 16:51:26
B
97
S
22
G
176
Posts: 4,109
Reputation: 103,021

Post » Sun Oct 30, 2011 11:30 am

Great one..Thanks. I will try soon.
B
10
S
1
G
2
Posts: 47
Reputation: 1,615

Post » Tue Nov 01, 2011 11:07 am

and the "or"?
I'm looking for it ^^
ImageImageImageImageImageImage
B
92
S
19
G
12
Posts: 1,192
Reputation: 18,276

Post » Tue Nov 01, 2011 1:46 pm

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.
B
97
S
22
G
176
Posts: 4,109
Reputation: 103,021

Post » Fri Feb 24, 2012 7:34 am

Dude this is epic. Thanks a stack!
B
16
S
2
G
4
Posts: 67
Reputation: 3,295

Post » Wed Feb 29, 2012 9:25 pm

@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

cacotigon2012-02-29 21:56:15
B
30
S
6
G
8
Posts: 232
Reputation: 6,119

Post » Wed Feb 29, 2012 11:59 pm

@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.rexrainbow2012-03-01 00:01:26
B
97
S
22
G
176
Posts: 4,109
Reputation: 103,021

Post » Thu Mar 01, 2012 6:34 am

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


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


cacotigon2012-03-01 06:37:53
B
30
S
6
G
8
Posts: 232
Reputation: 6,119

Post » Thu Mar 01, 2012 7:53 am

@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.rexrainbow2012-03-01 07:54:22
B
97
S
22
G
176
Posts: 4,109
Reputation: 103,021

Post » Mon Mar 19, 2012 12:03 am

Update:

Add version to 1.0
B
97
S
22
G
176
Posts: 4,109
Reputation: 103,021

Next

Return to Completed Addons

Who is online

Users browsing this forum: No registered users and 2 guests