Hi all,
First off, thanks for all of the support on the forums! I'll note that I searched forum posts and documentation and still having questions.
I'm having a little trouble understanding and coming up with an elegant solution for a scripting way to trigger an event at the start of the layout when the layout is loaded multiple times in a cyclic pattern. The existing "beforelayoutstart" event in ILayer empirically only run the first time the layout is started, but not if I go in the following pattern:
MenuLayout -> LevelLayout (event works here) -> ScoreLayout -> LevelLayout (event does *not* work here)
It's not very clear from the description in the ILayer documentation, which counterintuitively (unless I'm doing something wrong here) that "beforelayoutstart" event is *"Fired when the layout starts. "beforelayoutstart" fires just before On start of layout, and "afterlayoutstart" fires just after"* especially since the event sheet On start of layout does fire when I load LevelLayout a second time. It'd be nice to have documentation clarify either way.
Assuming only firing once before the *first* start of the layout is how it's intended (and I'm just not grossly misunderstanding events), I looked for other solutions:
1. [Doesn't work] Calling functions concerning objects on LevelLayout in the same function as my move to layout call. This doesn't work because the move to layout is performed at the end of the tick after all other code. Unless I'm missing something here too.
2. [Seems very inefficient] Storing a "layoutLastTick" variable and any functionality to be run on next layout, comparing current to previous layout every tick to decide whether or not to run.
3. [Went with this, but ugly] Using the event sheet solely for an actual "On start of layout" and then calling script inside. I imagine this is in reality as inefficient as solution two since the sheet runs each tick.
Anyone else come up with better solutions? Am I just misunderstanding the use of "beforelayoutstart" event or alternatives?