set an event trigger to a specific amount of time

Get help using Construct 2

Post » Sat Apr 14, 2012 11:24 am

Hi,

I want to setup an if statement so that if nothing is happening then a new event will start.

At the moment i have two global variables, onscreen and counter.

When nothing is happening both these would be at zero. What i want to do is set an if statement that says

'if counter is equal to or less than 0 and onscreen is equal to or less than 0 for 5 seconds' = then activate next group.

It has to be 5 seconds because there are points within a standard group event sequence when both variables might equal zero but that group isnt over with so i want to make sure a new event only occurs when a group is finished.

If anyway can say whether that if statement is possible and which system events to use would be useful thanks.
B
25
S
7
G
5
Posts: 185
Reputation: 5,056

Post » Sat Apr 14, 2012 1:43 pm

Try this:

Global number time_true = 0

+ Counter <= 0
+ Onscreen <= 0
-> Add dt to time_true

+ Else (in the latest beta)
-> Set time_true to 0

+ time_true >= 5
+ Trigger once
-> Do something

Basically this counts up time_true while the event is true, and resets to zero if the event is not true. Once the time_true reaches 5 (seconds), you can then run an event.
Scirra Founder
B
359
S
214
G
72
Posts: 22,951
Reputation: 178,578

Post » Sat Apr 14, 2012 2:37 pm

hi thanks that works, but i need to add a third condition to it... there is a text box that occasionally appears in the game, so i want to add the condition And when textbox is off screen.

I can see a system command Textbox is on screen (test if the object is ont he visible screen)

Is there an opposite to this. so that it tests if the object is not on the visible screen. So that the final list of commands would be:

+ Counter <= 0
+ Onscreen <= 0
+ Textbox is not on screen
-> Add dt to time_true

+ Else (in the latest beta)
-> Set time_true to 0

+ time_true >= 5
+ Trigger once
-> Do something
B
25
S
7
G
5
Posts: 185
Reputation: 5,056

Post » Mon Apr 16, 2012 10:08 am

Hi, In case this helps someone else, I had forgotten that when you add a conditional event to the event sheet that you could right click on the event and click invert to make it the opposite. Obviously I was haveing a dumb moment as that is what i needed above.

So the final event sheet would be:

+ Counter <= 0
+ Onscreen <= 0
+ Textbox is on screen (inverted)
-> Add dt to time_true

+ Else (in the latest beta)
-> Set time_true to 0

+ time_true >= 5
+ Trigger once
-> Do something
B
25
S
7
G
5
Posts: 185
Reputation: 5,056


Return to How do I....?

Who is online

Users browsing this forum: anty21ro, PavleNikolic and 23 guests