[SOLVED] How do I execute a command for X time

Get help using Construct 2

Post » Sun Jul 15, 2012 10:33 am

Hello there everyone! Just acquired this marvelous program and I'm trying to get started...

I've been searching around the forum for a way of executing a command for X time and the only thing i've found is something related to "ignore input" but that doesn't serve me...

What I need is something like this:

If CONDITION
Execute ANYACTION for X seconds

Command can be anything from user input to move object towards position, etc...

Is there a way anyone could help me?alejocazu2012-07-17 06:07:56
B
4
Posts: 5
Reputation: 610

Post » Sun Jul 15, 2012 7:10 pm

You could use the Wait action.

If CONDITION
-> Toggle Boolean/variable
-> Wait x seconds
-> Toggle Boolean/variable back to original

That way you will be able to use the variable to execute an action for a set amount of seconds.
B
33
S
12
G
7
Posts: 227
Reputation: 7,582

Post » Tue Jul 17, 2012 6:07 am

Well thanks for your reply! :) Wohoo!
B
4
Posts: 5
Reputation: 610

Post » Mon Dec 31, 2012 3:06 am

Is there a cleaner way to do this? For i to 100 etc?

For example:

I have an image which I wish to rotate, However, the built-in rotate function only rotates along the exact center of the image, regardless of where my image point is set. (-200,0 for the sake of argument)

So when I try to rotate manually, what I end up with is:

System / Every Five Seconds
     IMAGE rotate 20 degrees clockwise
     system / wait 0.2 seconds
     IMAGE rotate 20 degrees clockwise
     system / wait 0.2 seconds
     IMAGE rotate 20 degrees clockwise
        etc.

This makes the 60 degrees of rotation I was looking for, but it breaks it up into 3 movements. In order to get a fine animation, I would have to break it up further, rotating the image 10 degrees every 0.1 seconds. This would have six ticks, which is still not that great, especially since it would require six more lines of information.

With BASIC, you could run a FOR i to 1 loop... But how on earth would you do it here? I know there's a for loop available here, but I can't make it work. havenrocket2012-12-31 03:08:42
Everybody got to come out of the closet... does that mean I'm allowed to come out of the corner? Is that even funny anymore? Do parents still make their kids stand in corners when they mouth off?? These are the questions that keep me out of the really good schools.

havenisle.net
B
11
S
3
G
3
Posts: 27
Reputation: 2,695

Post » Mon Dec 31, 2012 1:48 pm

I guess this should be done easily with a System -> Compare Time condition.
B
15
S
3
G
5
Posts: 396
Reputation: 4,977

Post » Mon Dec 31, 2012 7:37 pm

@KFC thanks, I get it now.

Same example as above- a simple rotating slide effect...

STEP ONE:
Begin by making a global variable. (Mine is SLIDECOUNT, set to 0.)

STEP TWO:
Set up the time frame that you wish your slide to rotate. I want my frame to last for 3 seconds, then rotate clockwise for the duration of 1 second.

[quote]
System / Every 3 seconds
     ADD 1 to SLIDECOUNT
     System WAIT 1 Second
     SUBTRACT 1 from SLIDECOUNT
[/quote]

This Action simply causes the SLIDECOUNT variable to change from 0 to 1 for 1 second every three seconds.

STEP THREE:
Now we just have to tell the system what to do during the one second that SLIDECOUNT is going to be equal to 1. We can do that using the System / Compare Variable option.

[quote]
System / SLIDECOUNT = 1
     SLIDECOUNT / Rotate Clockwise 1.
[/quote]

And that's it.

When you run that, the system will wait for three seconds, start rotating your slide by 1, and for the the duration of SLIDECOUNT=1, it will just keep rotating by a single degree.

Lol... I was making it waaaaay harder than it needed to be.

Nothing against the seasoned vets, but...

[QUOTE=KFC] You could use the Wait action.

If CONDITION
-> Toggle Boolean/variable
-> Wait x seconds
-> Toggle Boolean/variable back to original

That way you will be able to use the variable to execute an action for a set amount of seconds.[/QUOTE]

... sometimes the psuedocode can be a bit vague. Structuring things closer to syntax really helps. I never would have imagined that it would have required multiple actions to achieve this particular task from KFC's psuedocode, which is grouped together like a paragraph, and leads one to believe that it could all be placed in one Action.

I'm not complaining, just trying to explain why it seems like we're asking the same question five times! ^__^
Everybody got to come out of the closet... does that mean I'm allowed to come out of the corner? Is that even funny anymore? Do parents still make their kids stand in corners when they mouth off?? These are the questions that keep me out of the really good schools.

havenisle.net
B
11
S
3
G
3
Posts: 27
Reputation: 2,695


Return to How do I....?

Who is online

Users browsing this forum: 99Instances2Go, Google [Bot], Magistross, mallorcaredes, zatyka and 28 guests