Sequence of execution onStartLayout across include sheets

Discussion and feedback on Construct 2

Post » Sun Jun 01, 2014 5:18 am

Hi,

To better structure the code of the game, I am using include event sheets extensively. I have one include event sheet that includes all other event sheets, and that is included in all other layout event sheets. Like this if i want to add event/action behavior across all game layouts in can do so by creating a new "include" event sheet.

E.g.

Layout1-Events sheet includes IncludeInAllEventSheets-Events.

IncludeAllEventSheets-Event includes
-includeEventSheet1
-IncludeEventSheet2
-includeEventSheet3
etc.

Now, my question. If I have an onStartLayout trigger in event sheet 1 and event sheet 2 and event sheet 3 and in Layout1-Events, can I assume that the order in which the onStartLayout will be triggered will be according to the include event sheet sequence?

thanks,

Dan

p.s. If no order can be guaranteed, then I would suggest adding a priority/sequence attribute to each Event trigger, which ensures that same triggers are ordered in the event queue. In essence turning them into "nested" events as it were
B
8
S
4
G
1
Posts: 205
Reputation: 1,354

Post » Sun Jun 01, 2014 5:26 am

One approach I am trying now to overcome this is to turn all onStartLayout code segments into Functions, and then have only one onStartLayout that calls all functions.,
B
8
S
4
G
1
Posts: 205
Reputation: 1,354

Post » Sun Jun 01, 2014 12:09 pm

I think the order is guaranted (aka : read your main event sheet in the good order, if you come across an include when you are reading, read that included then come back), but I am not sure if I actually tested this or if I considered true by default.
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
52
S
22
G
18
Posts: 2,122
Reputation: 17,093

Post » Sun Jun 01, 2014 12:42 pm

Included event sheets are always read first, regardless of where the Include event sheet code is used in the event sheet. They are, however, read in the order that they're called in the "parent" event sheet, so there is certainty that can be relied upon.
B
57
S
15
G
11
Posts: 912
Reputation: 12,606

Post » Sun Jun 01, 2014 8:24 pm

Thanks,

What about triggers, such as on start layout triggers are they processed in sequence too.

In one implementation I had included a second condition to each on start layout, such as layoutState=1, layoutState=2
like this i tried to ensure that on start layout in a base sheet is only triggered after an on start layout in an include sheet, but this requires a kind of "stickiness" of triggers: the trigger later needs to "wait" until the second condition is true and then fire. But i wasnt sure if this really worked consistently (it seemed to have worked though, i just wasnt sure if its guaranteed, or a fluke).
B
8
S
4
G
1
Posts: 205
Reputation: 1,354

Post » Sun Jun 01, 2014 9:17 pm

On start triggers are processed in that order. So if you have On start events in your included event sheet and your parent sheet, it'll first run in the included sheet, then the parent sheet. If an action in your parent sheet is dependent on something happening first in your included sheet, it should work fine in this case.

I use this principle when creating a game that has multiple levels that share one common event sheet but each have their own sheet for special circumstances (in a puzzle game, for example): I can be sure that anything that's set both in the common sheet and in the unique sheet will be overwritten by the unique sheet if necessary.
B
57
S
15
G
11
Posts: 912
Reputation: 12,606

Post » Wed Jun 04, 2014 4:10 pm

GeometriX wrote:Included event sheets are always read first, regardless of where the Include event sheet code is used in the event sheet. They are, however, read in the order that they're called in the "parent" event sheet, so there is certainty that can be relied upon.


@Geometrix @grossd

I've done a quick test, and it seems that it is as Geometrix said for the On start of layout (maybe also for every trigger condition), but not in case of a every tick, where the positionning of the include is of importance.
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
52
S
22
G
18
Posts: 2,122
Reputation: 17,093

Post » Wed Jun 04, 2014 4:27 pm

@Aphrodite, ooh, that's very interesting. Thanks for doing such a conclusive test. Now that I think about it, I'm sure that inconsistency has caused me problems in the past!
B
57
S
15
G
11
Posts: 912
Reputation: 12,606

Post » Thu Jun 05, 2014 1:32 am

Thanks for testing @Aphrodite. Do you think you could provide a link to the project file ... But, thinking theoretically, its hard to conclusively prove with test cases.

I am trying to instead use call backs and varying secondary conditions (states) to order sequences independent of the layout include sequence; and for critical items I currently duplicate them in the "parent" layout ... (for example for processing that has to happen on end layout)
B
8
S
4
G
1
Posts: 205
Reputation: 1,354

Post » Fri Jun 06, 2014 1:38 am

grossd wrote:Thanks for testing @Aphrodite. Do you think you could provide a link to the project file ... But, thinking theoretically, its hard to conclusively prove with test cases.

I am trying to instead use call backs and varying secondary conditions (states) to order sequences independent of the layout include sequence; and for critical items I currently duplicate them in the "parent" layout ... (for example for processing that has to happen on end layout)


Have fun : https://dl.dropboxusercontent.com/u/100 ... ering.capx

Also as an advice, I personnaly try to never use any actions or conditions in the Main sheet, and the only times I do, I don't use triggers, but rather variable comparaison and such (which generally serves the purpose of reducing the nuber of included sheets depending on some values), so I've never encountered this problem, it seems to only affect triggers (maybe a bug report could be done since it goes a little counter-intuitive wise, not that it would be corrected, but just to have a trace of this for the future..).

@GeometriX

@grossd
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
52
S
22
G
18
Posts: 2,122
Reputation: 17,093


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 0 guests