do after n seconds

Get help using Construct 2

Post » Sun Feb 23, 2014 2:21 am

How do "I do after n seconds" do something?

What I am trying to achieve is "do every n seconds until xxx happens" for movement, using recurrence.
B
4
Posts: 17
Reputation: 232

Post » Sun Feb 23, 2014 3:08 am

The easiest way I've found you can achieve this is the following:

* Create a global variable and call it something like: "ActionHappened" and set it's default value to 0.
* Create a timer that runs every x seconds if the variable ActionHappened = 0
* Elsewhere you would have your action set the value of ActionHappened to 1 whenever the action you are waiting on has been triggered
* Then on your earlier timer function I would put an else and then perform whatever code actions you want to perform

If you need further explanation, just ask.
B
6
S
1
Posts: 43
Reputation: 536

Post » Sun Feb 23, 2014 10:39 am

Works inefficient. The whole idea behind my movement is to do the check every x seconds only if ActionHappened=0. Your solution would still be checking the condition even after ActionHappened=1. For movement ActionHappened == If The player have reached the point pointed by mouse do set ActionHappened to 1.

What I am trying to achieve:
<SYstem>Are you there? <Player> NO <System> I move Player towards target.
<SYstem>Are you there? <Player> NO <System> I move Player towards target.
<SYstem>Are you there? <Player> NO <System> I move Player towards target.
<SYstem>Are you there? <Player> Yes <System> Ok it's fine. I won't be troubling you again.

What I get using your solutio:
<SYstem>Are you there? <Player> NO <System> I move Player towards target.
<SYstem>Are you there? <Player> NO <System> I move Player towards target.
<SYstem>Are you there? <Player> NO <System> I move Player towards target.
<SYstem>Are you there? <Player> Yes
<SYstem>Are you there? <Player> Yes
<SYstem>Are you there? <Player> Yes - Yes for f*ck sake's I am where I should be so shut the f*ck up!


I will be doing RPG so I can allow myself to have one useless "Every thick" running but I wonder what will happen if need to do Paltfromer with plenty of things running.
B
4
Posts: 17
Reputation: 232

Post » Sun Feb 23, 2014 12:57 pm

i would create a variable lets call it x = 0
ok so your example lets say when the system says are u there and you say "yes" event will be x=1
and under condition it would be "every n seconds' aswell as "if x = 0" ask "are you there"
sorry im bad at explaining but that should work for what u need
B
5
S
1
Posts: 21
Reputation: 579


Return to How do I....?

Who is online

Users browsing this forum: NN81 and 26 guests