I have another script problem. I won't post the whole script here since it would be too long. I believe I know where the problem came from, but don't know why.
// script "a"
void main( void )
{
int &control = 0;
blah;
blah;
blah;
loop:
blah;
blah;
blah;
blah;
// at certain condition
if (&control ==0)
{
&control = 1;
&asprite = create_sprite(&randx, &randy, 0, 0, 0);
sp_script(&asprite, "a");
blah;
blah;
}
blah;
blah;
goto loop;
}
In short, I was calling the same script within a script. It worked fine up to about 20 to 25 scripts called. Then the local variable &control ceased to function at all. I did have a command using scripts_used() to control the total number of scripts used. Anyone know why it ceased to work after about 20 to 25 scripts.
Thank you very much.
: I have another script problem. I won't post the whole script here since it would be too long. I believe I know where the problem came from, but don't know why.
: sp_script(&asprite, "a");
Heh
: In short, I was calling the same script within a script. It worked fine up to about 20 to 25 scripts called. Then the local variable &control ceased to function at all. I did have a command using scripts_used() to control the total number of scripts used. Anyone know why it ceased to work after about 20 to 25 scripts.
This is one of the few things I haven't found a work-around for. Calling bunches scripts just does this sometimes. I never understood exactly why. Or why sometimes you can get away with it and sometimes you can't.
All you can do is try and do things difernetly and hope it works. If you can find a way to use less variable, or less scripts, that's likely ro help.
: : I have another script problem. I won't post the whole script here since it would be too long. I believe I know where the problem came from, but don't know why.
: : sp_script(&asprite, "a");
: Heh
: : In short, I was calling the same script within a script. It worked fine up to about 20 to 25 scripts called. Then the local variable &control ceased to function at all. I did have a command using scripts_used() to control the total number of scripts used. Anyone know why it ceased to work after about 20 to 25 scripts.
: This is one of the few things I haven't found a work-around for. Calling bunches scripts just does this sometimes. I never understood exactly why. Or why sometimes you can get away with it and sometimes you can't.
: All you can do is try and do things difernetly and hope it works. If you can find a way to use less variable, or less scripts, that's likely ro help.
Well, if all you're trying to do is rerun thru the hole script, at the bottom you can just put:
Main()
assuming that main is the function you want to loop. Or even a loop: and goto loop; would work. Maybe this isn't what you're trying to acomplish...hope it helps.
: Well, if all you're trying to do is rerun thru the hole script, at the bottom you can just put:
: Main()
: assuming that main is the function you want to loop. Or even a loop: and goto loop; would work. Maybe this isn't what you're trying to acomplish...hope it helps.
Since the main purpose of my script is to create another sprite with the same script, your answer is not for me. :(
After several trial-and-error, I concluded that you can only have 200 local variables running at the same time. And that explained Paul's solution. Originally, I had 10 different local variables for the script and it can be called only 19 times. Finally I reduced the number of local variables to 3 by repeatedly using them at different places as different variables. That way, I can call it up to 65 times.
It is interested that seth did not mention this restriction.
From the Official DMod Faq: http://www.prowler-pro.com/dmods/dmod-faq.html
Q: What are some of the limits & thresholds?
A: You can have up to 99 sprites on one screen. You can have as many as 200 scripts running at once. You can set up to 200 global variables. You can place up to 50 sprites in a sequence (animation or sprite set) and up to 1000 sequences total (for a grand total of 50000 frames). You can have up to 600 "set_sprite" commands in dink.ini. Up to 100 "callbacks" can be set at once. The game can load up to 99 sounds.
It says, you can have as many as 200 scripts running at once...
To be checked :)