Jump to content
Sign in to follow this  
sknam

Is it possible to have a wait between 2 actions in an activation trigger?

Recommended Posts

Is it possible to have a wait between 2 actions in an activation trigger?

ab setunitpos "down"; sleep 10; ab setunitpos "middle"

When I tried this, it looks like the game read and executes all actions immediately.

Is there syntax to make a pose in the same activation field?

Share this post


Link to post
Share on other sites

In field "on activation" all sleep commands don't work.

Try this:

tmp = [] spawn {ab setunitpos "down"; sleep 10; ab setunitpos "middle";}

Share this post


Link to post
Share on other sites

Great !

Thank you Przemek_kondor!

I don't understand why the game allow this with a wait command: tmp = [] spawn{...

but it works :o

Edited by SKNAM

Share this post


Link to post
Share on other sites

It works because the trigger code is run as part of a main game thread, and as such it's not allowed for it to "block" execution - otherwise the whole game would stop for the duration of the sleep (or something like that). The "spawn" command creates a new separate thread of execution, so the spawn's code block is run in parallel with other scripts.

As a further aid to understanding; if you were to do:

player sideChat "hi there";
tmp = [] spawn {ab setunitpos "down"; sleep 10; ab setunitpos "middle";};
player sideChat "bye now";

Then when the trigger is activated, the player would immediately say "hi there" AND "bye now", while the unit 'ab' would go prone and after 10 seconds kneel.

Edited by some kind of guy
Removed suggesting to use nil = ... don't do that!

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×