The Dink Network

Question

August 28th 2005, 05:29 PM
pig.gif
Is there a limit to how many local variables can co-exist in one script?

Edit: One that realisticly could ever be a problem, below 700 for instance?
August 28th 2005, 05:45 PM
custom_magicman.gif
magicman
Peasant They/Them Netherlands duck
Mmmm, pizza. 
In one script... I don't know. But there is an overall variable limit. I.e. the total number of variables used, that is all locals of all running scripts and all globals. Too bad I forgot the number
August 28th 2005, 06:39 PM
pig.gif
If I were to spawn new scripts to continue and spawn more variables the limit would never be a problem for me, right (below a 700 odd)?
August 28th 2005, 06:57 PM
custom_magicman.gif
magicman
Peasant They/Them Netherlands duck
Mmmm, pizza. 
I just looked it up in the Almighty DinkC Reference. It says:

All make_global_int() variables and all "int" variables of all running scripts share a single pool of 248 slots for variables.

LATE ADDITION: There are also some hints in it to make maximum use of as few as possible variables:

- define them sparingly, re-using variables when it can be done safely;

- define them later in the script when it makes sense. For example, if the defining of a variable can be put off until the "die()" proc of a monster brain, the variable uses no slots until the script is almost ready to be discarded from memory.

- use kill_this_task() to kill scripts no longer needed.


Next to those, there are also a few script tricks. Think of editor_seq() abuse and supervars. If you don't know how they work, don't bother with it
August 28th 2005, 07:00 PM
pig.gif
Oh shoot, I'm really gonna have to start being less heavy on locals in this script i'm working on. I'm less than a fith through and ive used aboout 40 locals.
August 28th 2005, 07:25 PM
custom_king.png
redink1
King He/Him United States bloop
A mother ducking wizard 
Hmm, what are you doing?

If you really, really need more slots, you can always use the sprite attributes to hold some. That could get confusing though.
August 29th 2005, 07:03 AM
pig.gif
I've found a way around it, it will just be slightly less good. As for what I'm doing, If my dmod is a complete flop I will release it perhaps in a wierd dmod with a few other less cool things which along with it which people will be free to steal the source from to use in there dmid, but I dont want to say what it is, because its a very novel mini game, and if people expect it, it will lose some novelty.