Any potential way to create a "Wait (Time) Unless?" [Done]

0 favourites
  • 2 posts
From the Asset Store
An educational game for Times Table. An easy to use template for developers to build larger games
  • (This has been solved. Read the reply below this long post for the solution.)

    I require a condition that can emulate this, otherwise, the wrong thing could happen.

    (I can work with a wait command that can be stopped by an action)

    My scenario (If you get the idea, this post is over):

    • Player
    • Booleans:

    - Preparing (Prevents other actions while an action is in progress) (State is False)

    - FlashThrowReady (Takes note when a wait command has finished) (State is False)

    • Image Points

    - ImagePoint0 (Margin, center of Player)

    - ImagePoint1 (In front of the Player)

    • Flashbang
    • FlashbangPin
    • FlashbangStriker
    • Keyboard
    • Audio

    My input will be:

    Hold down T

    When T is pressed and Preparing is False, (Conditions met)

    Toggle Preparing (State now switched to True)

    Play "Pull Pin" at -10dB

    Wait 0.43 seconds (waits until a certain time in the audio passes)

    Spawn at Player, ImagePoint0, FlashbangPin (Graphical Use)

    Toggle FlashThrowReady (State now switched to True)

    Wait 5 seconds (When the next sub event should start)

    Sub Event, Is FlashThrowReady (State is True so continue)

    Spawn at Player, ImagePoint1, FlashbangStriker (Object for Graphical Use)

    Spawn at Player, ImagePoint1, FlashbangThrown (Object)

    Toggle FlashThrowReady (State now switched to False)

    Toggle Preparing (State now switched to False)

    What happens is:

    T is held down

    Pin spawns after 0.43 seconds

    FlashbangStriker and FlashbangThrown spawns after 5 seconds

    Everything is good, this is what should happen.

    Go through this again, except these inputs are now:

    Hold down T for 3.43 seconds

    Release T

    Hold down T

    If you read the script, what will happen is:

    T is held down

    Pin spawns after 0.43 seconds

    T is released, then held down (Remember: Preparing and ThrowFlashReady is back to False, Preparing is now True)

    FlashbangStriker and FlashbangThrown spawns (the objects were thrown)

    Pin spawns after 0.43 seconds (Now FlashThrowReady is True)

    FlashbangStriker and FlashbangThrown spawns after 2 seconds

    FlashbangStriker and FlashbangThrown spawns after 3 seconds

    The problem is, the first wait is still going on and the sub event will run when it finishes (spawning FlashbangStriker/Thrown because conditions meet).

    The idea is to discontinue the wait when I release T, so if "Wait (Time) Unless" is a thing and send the inputs again:

    • Since actions do not involve conditions, I shall say it also works like a "Wait for signal"

    When T is pressed and Preparing is False, (Conditions met)

    Toggle Preparing (State now switched to True)

    Play "Pull Pin" at -10dB

    Wait 0.43 seconds (waits until a certain time in the audio passes)

    Spawn at Player, ImagePoint0, FlashbangPin (Graphical Use)

    Toggle FlashThrowReady (State now switched to True)

    Wait 5 seconds unless Signal "Stop"

    Sub Event, Is FlashThrowReady

    Spawn at Player, ImagePoint1, FlashbangStriker (Object for Graphical Use)

    Spawn at Player, ImagePoint1, FlashbangThrown (Object)

    Toggle FlashThrowReady

    Toggle Preparing

    When T Released (Remember, not a sub event) (Triggered by "Release T")

    Signal "Stop" (Cancels Wait)

    Spawn at Player, ImagePoint1, FlashbangThrown (Object)

    Toggle FlashThrowReady (State now switched to False)

    Spawn at Player, ImagePoint1, FlashbangStriker (Object for Graphical Use)

    Toggle Preparing (State now Switched to False)

    Skipping over to when I release T,

    T is released, then held down (Remember: Preparing and ThrowFlashReady is back to False, Preparing is now True)

    FlashbangStriker and FlashbangThrown spawns (the objects were thrown)

    Pin spawns after 0.43 seconds (Now FlashThrowReady is True)

    FlashbangStriker and FlashbangThrown spawns after 5 seconds

    Problem solved. Instead of 3 flashbangs, only 2 spawns. One because I released to throw the grenade, and another because I dropped it (because I held it too long...? That's not what happens realistically but its funny to stun yourself)

    Over complicated scenario to show the easy solution.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I'm sorry, I like to keep efficient and use variables/booleans/text as little as possible. I can use a variable to fix this problem.

    Enjoy the ~30 minutes of writing above me. Or not.

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