Help with conditions that should not trigger again

0 favourites
  • 5 posts
From the Asset Store
Game with complete Source-Code (Construct 3 / .c3p) + HTML5 Exported.
  • Hi there!

    First time poster here, but I've been tinkering with Construct for a while already. However, this is my first project using Functions and generally more elaborate events. And I ran into a problem that I just can't wrap my head around!

    The game is basically two games in one, so feel free to ignore eventsheet1 (it's not being called on) and only observe the left side of the screen. (Sure, the two "separate games" might conflict, but I'm very certain that's not it)

    The Dialogue Game works like this: Text is being displayed one after the other and at the end the player is allowed to pick an answer (press 1, 2 or 3). The answers the player didn't select are set invisible and after having pressed a button, they're naturally not allowed to choose again.

    The Problem: The answers are set visible once more after a short period of time and the player can pick again.

    I think the root of the disaster lies somewhere here:

    While pressing a button triggers the function which sets answerAllowed to 0 and thus prevents the answers from being made visible again, it could be triggered in the miniscule timeframe until the function call. However, adding the condition "only trigger once while true" only broke the game further. What's more is that the answers don't become visible right away, but after a second or so. Very strange.

    Can anyone help with this? I really hope it's something stupid, so I can feel a bit stupid and move on quickly. : )

    Thanks for reading!

    EDIT: Whoops, can't post download links. When I try to edit the post to attach the file the site breaks? D :

    EDIT 2: Welp, here's the chopped up download link: dl . dropboxusercontent . com/u/7648042/games/GameAWeek/%234/Dialogue%20-%20please%20help%21 . capx

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hello!

    I think the problem here is that keyboard press is a trigger and you set this trigger in the beginning, because your answerAllowed is true. After this it doesn't matter what value answerAllowed gets because the trigger was set already.

    If you put a condition after every keyboard press condition (for example test your answerAllowed variable) then it should work. This means you must test for every keyboard event. I hope you understand, i don't know how to explain better in the moment.

  • Hi!

    Thank you for both the quick reply and the explanation - I had never even considered that the order is important. But I don't quite understand what you mean by conditions after keyboard presses?

    I put the function which sets the answerAllowed value to 0 to the top of the sheet so it would be executed first when construct runs through the whole sheet and that seems to work! Fun timing, too - just had a friend look at my code and we both didn't know about the importance of event order. He ended up putting it right by accident. : D

    But it was only a hypothesis and nothing can make up for a proper confirmation!

    tl;dr: Fixed for now, but not 100% sure why.

  • I don't know what exactly is happening in your case, but you must remember that have 2 different types of events: normal events and triggers (the ones with the green arrow in the front). Normal events run from top to bottom in a loop, but triggers will not be looked after in that loop anymore, only if they are 'fired' (for example user presses a key).

    In your case it is good (if i am right, don't nail me on it right now, i have C2 not by my hand in the moment) that you put another condition (with right mouse click) under EVERY of your keyboard triggers to look after answerAllowed = 1.

  • I see, thank you for clarifying!

    That makes sense and I'll edit it in or at the very least I'll know what might come back to bite me in the butt.

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