Timed Events (Do After) Problem

JeffreyDriver

  • Posts: 2262
I've been trying to get to grips with timed events, and despite my reading and experimenting I can't quite get my head around something.  I have a script that stuns enemies, and it does work in part, but the effects aren't removed after a set time. I've been trying to remove the effects using the 'Do After' block, and I've tried several different ways. Please see a screenshot attached with two methods I've been trying.

When enemies are hit, they change colour, drop, and buzz around on the floor. After 10 seconds they should revert back to their original colour, get up and start flying around again. I've been trying to get this working for two days, and would appreciate a little help. Thanks.

SadiQ

  • Posts: 1795
The Do after [] seconds block doesn't stop the rest of the code from running. It will simply remember something that will run after x seconds.
So in your last case, your code will check if freezeDelay = 1 before the Set freezeDelay =1 block.
Proud member of the League of Idiotic Stencylers! Doing things in Stencyl that probably shouldn't be done.

JeffreyDriver

  • Posts: 2262
The Do after [] seconds block doesn't stop the rest of the code from running. It will simply remember something that will run after x seconds.
So in your last case, your code will check if freezeDelay = 1 before the Set freezeDelay =1 block.

Thanks for explaining that. However, I'm still having trouble. Any idea why the code in this screenshot wouldn't work? In principal it seems quite simple, but I'm obviously missing something.

I've also tried keeping the 'set freezedelay'  block and attaching 'if freezedelay' to the actor.

SadiQ

  • Posts: 1795
I have a feeling that once you kill the actor (the kill self block), the Do after [] seconds block will not run.  (I could be wrong thou, so put a print [] block inside the timer and test with and without killing the actor).
Proud member of the League of Idiotic Stencylers! Doing things in Stencyl that probably shouldn't be done.

JeffreyDriver

  • Posts: 2262
I have a feeling that once you kill the actor (the kill self block), the Do after [] seconds block will not run.  (I could be wrong thou, so put a print [] block inside the timer and test with and without killing the actor).

Thanks! You were absolutely right. Killing the actor, kills the code attached to it. Blindingly obvious now I think about it. I was trying to be clever by using the code once, on just the bullets, but I stuck it to an actor, and with a little tweaking it's working perfectly. Thanks again.