How do I make a function wait for a signal

0 favourites
  • 6 posts
  • 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:

    -> On function showPages
         -> ConditionsForPage1   ::  CallFunction(GeneratePage1)
                                 ::  Wait for user pressing ENTER
         -> ConditionsForPage2   ::  CallFunction(GeneratePage2)
                                 ::  Wait for user pressing ENTER[/code:2nfmchpm]
    ...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?
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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.

  • Could you be a bit more specific please? How exactly would that work?

  • -> 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.
  • 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.

  • fundation2000

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

    I made a quick test:

    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!

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