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

Discussion and feedback on Construct 2

Post » Sat Aug 05, 2017 2:46 am

(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.
Last edited by thegamecracks on Sat Aug 05, 2017 3:45 am, edited 1 time in total.
B
6
S
2
G
13
Posts: 2
Reputation: 6,982

Post » Sat Aug 05, 2017 3:43 am

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.
B
6
S
2
G
13
Posts: 2
Reputation: 6,982


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 13 guests