Spawn and external!
Gah, I want to spawn a script with a loop in it, getting a variable from the main script that is attached to a sprite without halting the main script. Word.
External() apparently halts the main script until kill_this_task() or something is run from the external script.
I want to pass a variable to the spawned script from the main script. Like this here external:
But the loop in rloop halts the main script so I want to liiiiikeee:
Maybe I'm too tired.
My guess is taking advantage of script_attach or something since that's what spawn is using.
External() apparently halts the main script until kill_this_task() or something is run from the external script.
I want to pass a variable to the spawned script from the main script. Like this here external:
void main (void) { int &sx = sp_x(¤t_sprite, -1); int &sy = sp_y(¤t_sprite, -1); external("rloop", "main", &sx, &sy); //&sx = &arg1, &sy = arg2 ...rest of script... }
But the loop in rloop halts the main script so I want to liiiiikeee:
spawn("rloop", "main", &sx, &sy); //&sx = &arg1, &sy = arg2
Maybe I'm too tired.

You could do something really weird and ridiculous instead.
create a sprite
set useless variable such as sp_gold to the vars you want remembered(&sx, &sy).
use sp_script in place of external/spawn.
And *ta-da* problem solved.
create a sprite
set useless variable such as sp_gold to the vars you want remembered(&sx, &sy).
use sp_script in place of external/spawn.
And *ta-da* problem solved.
You could use spawn to do something like this, but spawn doesn't have the same arguments external does.
I usually just set some global juggle variables to whatever I want the spawned script to use. Leprochaun's sp_script solution might be better.
I usually just set some global juggle variables to whatever I want the spawned script to use. Leprochaun's sp_script solution might be better.
So there's no easier way huh.

Sure there's some ways to do this. The easiest one is to use a global variable, one that you reserved for scripting tricks such as this. If you make use of the variable (set it to a local in the spawned script) without a wait() in between you'll never run into issues with it.
The other way is writing the data to a sprite on screen and retrieving it from that, for example in its sp_gold() or editor_seq. You could use a sp(5) or whatever to target it, as long as there are 5 sprites on the screen. I wouldn't use this method, but it's functional.
I also like Leprochaun's solution, it would work fine. If you could, try it with the globals though, it's much more reliable and doesn't count on sprites to do their job.
The other way is writing the data to a sprite on screen and retrieving it from that, for example in its sp_gold() or editor_seq. You could use a sp(5) or whatever to target it, as long as there are 5 sprites on the screen. I wouldn't use this method, but it's functional.
I also like Leprochaun's solution, it would work fine. If you could, try it with the globals though, it's much more reliable and doesn't count on sprites to do their job.