How do I make a function wait for a signal

Get help using Construct 2

Post » Wed Aug 26, 2015 3:22 pm

I am working on something more complex, and I have a big number of semi-dynamically created pages I need to display to the user (50+).

I tried to avoid making a layout for each page, since they are much more easily manageable as layers and a single event sheet. So I created a layer for each page and then I use conditions to select which layers will be visible and which ones will not. Then, when the player hits "Enter", I need the Layer to change. Basically, I am trying to achieve something like this:

Code: Select all
-> On function showPages
     -> ConditionsForPage1   ::  CallFunction(GeneratePage1)
                             ::  Wait for user pressing ENTER
     -> ConditionsForPage2   ::  CallFunction(GeneratePage2)
                             ::  Wait for user pressing ENTER

...and so on.
Each Generation function resets all layers to "invisible" first, before making only the required layer visible. I have an event sending a signal upon pressing "ENTER".

The problem is the "wait for signal" action, which only stops the actions in one branch of the event, but the following branch will start anyway. So in the above example, as soon as I run "showPages", it will instantly display Page2, ignoring any attempt to stop after showing Page1.

I cannot place the page generation as sub-events, because the conditions for each page are individual. I couldn't figure out how to use the "rex_waitevent" plugin for this and cannot think of any other way to do it.

How would you solve this problem?
B
10
S
2
Posts: 32
Reputation: 672

Post » Wed Aug 26, 2015 3:25 pm

Have you tried just making a second function that happens when the player presses enter? One function to generate, another function for the user input. That sounds like essentially what you're trying to do anyways.
B
103
S
38
G
19
Posts: 962
Reputation: 17,996

Post » Wed Aug 26, 2015 3:58 pm

Could you be a bit more specific please? How exactly would that work?
B
10
S
2
Posts: 32
Reputation: 672

Post » Wed Aug 26, 2015 4:46 pm

Code: Select all
-> On function showPages
     -> ConditionsForPage1   ::  CallFunction(GeneratePage1)
     -> ConditionsForPage2   ::  CallFunction(GeneratePage2)
-> On Enter Pressed             :: CallFunction(ShowPages)


Just put all of your events to show pages into its own function that you call when they press enter. Just reference whatever variables you set up in the generating functions so it shows the right stuff. No need to pause a function and wait, just make that part its own function.
B
103
S
38
G
19
Posts: 962
Reputation: 17,996

Post » Wed Aug 26, 2015 4:49 pm

I need each layer to show separately, one after the other, after the user presses enter.

So it should show page 1, then wait for the player to press enter, show page 2, then wait for the player to press enter, show page 3, then waits... and so on.
B
10
S
2
Posts: 32
Reputation: 672

Post » Wed Aug 26, 2015 5:01 pm

@fundation2000

Like C-7 said, you should separate the showing of pages from the waiting for input...

I made a quick test: http://www.rieperts.com/games/forum/ChangePage.capx

But, I would seriously think about creating your pages as you need them, rather than pre-building them in the editor. 50+ pages is a lot of layers to manage, and if you want to change the general look, you will have a big job on your hands!
B
96
S
33
G
20
Posts: 438
Reputation: 17,665


Return to How do I....?

Who is online

Users browsing this forum: beohs, Yahoo [Bot] and 12 guests