Do after in a global custom block

Luyren

  • *
  • Posts: 2807
It doesn't work (and I guess someone said it's not suppose to work anyway), but is there an alternate way to do it? What I'm trying to do is a generic global custom block that changes the value of an attribute, and after a time return this attribute to the original value.
My Stencyl resources are available here: https://luyren.itch.io/
Cutscenes, RPG Elements, Particles, Map System and many more.

HNF

  • Posts: 232
Do after doesn't work in a global custom block because it doesn't have access to the scene(?) property of time.

I'm not sure how to do this. You could do something like
Code: [Select]
var i:uint = 0;
while (i < 100)
{
i ++=1;
}
return object;
Except it would create an FPS issue while it is waiting.
I don't think it would work as a global custom block.

Justin

  • *
  • Posts: 4716
Hm.. I did this recently, but it's in code.

Code: [Select]
var t:TimedTask = new TimedTask
(
function(timeTask:TimedTask):void
{
//code to process goes here
},
thousandthsOfSecondsToWait,
false
);
(FlxG.state as GameState).addTask(t);
For Live Support: Join our discord server and ping me @justin.
I'm most often available between 10am and 10pm Japan time. (GMT+9)

Luyren

  • *
  • Posts: 2807
Hm.. I did this recently, but it's in code.

Code: [Select]
var t:TimedTask = new TimedTask
(
function(timeTask:TimedTask):void
{
//code to process goes here
},
thousandthsOfSecondsToWait,
false
);
(FlxG.state as GameState).addTask(t);

Question: in the code to process, would just copying the preview code of the custom block there work? Also, where can I put a number attribute as the desired wait time in this code?
My Stencyl resources are available here: https://luyren.itch.io/
Cutscenes, RPG Elements, Particles, Map System and many more.

Justin

  • *
  • Posts: 4716
Unless the preview code puts spaces where it shouldn't (such as in the middle of an increment sign "+ +"), I think it should work.

The wait time goes on the line after the functions closing curly brace. Replace thousandthsOfSecondsToWait with a var or number. Use "1000 * (...)" to work with seconds, just like the doAfter block.
For Live Support: Join our discord server and ping me @justin.
I'm most often available between 10am and 10pm Japan time. (GMT+9)