Question

Post your scripting questions / solutions here

Moderator: Moderators

Post Reply
$oldier Of Ra
Lieutenant Colonel
Posts: 404
Joined: Sun Oct 16, 2005 7:16 pm
Location: Belgium
Contact:

Question

Post by $oldier Of Ra »

I know there is a limit of how many variables I can have in an array.
But is there a limit to how many variables I can have defined at the same time?
Our official website: http://www.mohaairborne.co.cc
(Still accessible through http://mohaaclantb.tk and http://users.skynet.be/mohaaclantb/)

For all your bot needs!!!!

$oldier Of Ra.
Rookie One.pl
Site Admin
Posts: 2752
Joined: Fri Jan 31, 2003 7:49 pm
Location: Nowa Wies Tworoska, Poland
Contact:

Post by Rookie One.pl »

I'm sure there is. There's no way to find the value, though, other than getting as many vars in a script as possible and checking the number.

What do you need that for, anyway? I'd risk saying that if you run out of variables, you're a really bad coder.
Admin
Image
Image
Honour guide me.

here's my stuff - inequation.org | here's where I work - thefarm51.com
$oldier Of Ra
Lieutenant Colonel
Posts: 404
Joined: Sun Oct 16, 2005 7:16 pm
Location: Belgium
Contact:

Post by $oldier Of Ra »

No reason actually, I was just wondering, I'm making lots of scripts (for my server) and I don't want to suddenly come to such an error.

EDIT: Ah I think I found the size. Someone had a problem with having too many entries in his array at tmt:

Code: Select all

The required variable stack size of 15226 exceeds the statically allocated variable stack of size 1024.
Increase SCRIPTTHREAD_VARSTACK_SIZE to at least 5226 and recompile.
I think the "1" in the first number is a typo (as is the case with many errors in mohaa). So I assume it's 5226 for the number of variables and 1024 per variable (= array). I think I won't ever have to worry about that then. :)
Our official website: http://www.mohaairborne.co.cc
(Still accessible through http://mohaaclantb.tk and http://users.skynet.be/mohaaclantb/)

For all your bot needs!!!!

$oldier Of Ra.
Rookie One.pl
Site Admin
Posts: 2752
Joined: Fri Jan 31, 2003 7:49 pm
Location: Nowa Wies Tworoska, Poland
Contact:

Post by Rookie One.pl »

I think you misinterpreted the message a bit. This 5226 (or 15226, I wouldn't be so sure as to which one here is a typo) is actually the number of variables that the scripter put in his script, not a limit of the scripting engine. The developers were just trying to be make the message more meaningful to themselves during any debugging they might be doing by including that number.

Guessing by the constant name (SCRIPTTHREAD_VARSTACK_SIZE), I'd say that they implemented the scripting engine using a per-thread stack system with a fixed size of 4kB (1024 * 4 bytes; I bet that the stack is 32-bit and holds either integers, floats or pointers) per thread, regardless of the type of variables and their organization (i.e. 2 integer variables and a 2-element integer array both take up the same amount of space on the stack).

By the way, it's funny how all programmers have a habit of rounding constants to the nearest power of 2. I do it too. :)
Admin
Image
Image
Honour guide me.

here's my stuff - inequation.org | here's where I work - thefarm51.com
$oldier Of Ra
Lieutenant Colonel
Posts: 404
Joined: Sun Oct 16, 2005 7:16 pm
Location: Belgium
Contact:

Post by $oldier Of Ra »

Hmm, I see so if I understand correctly, it's quite impossible to "run out of" vars. 4 kb per thread is a lot!
Our official website: http://www.mohaairborne.co.cc
(Still accessible through http://mohaaclantb.tk and http://users.skynet.be/mohaaclantb/)

For all your bot needs!!!!

$oldier Of Ra.
Rookie One.pl
Site Admin
Posts: 2752
Joined: Fri Jan 31, 2003 7:49 pm
Location: Nowa Wies Tworoska, Poland
Contact:

Post by Rookie One.pl »

Indeed it is a lot. I might be wrong about it being per thread, though, the fact that they named the constant SCRIPTTHREAD_VARSTACK_SIZE doesn't necessarily mean that. Those guys are known not to follow naming conventions closely.
Admin
Image
Image
Honour guide me.

here's my stuff - inequation.org | here's where I work - thefarm51.com
Post Reply