Script Limits

Post » Fri Feb 05, 2010 10:02 pm

From MWSFD:

Character Limit: There is a limit of the maximum number of characters per script. It is somewhere around 30000 characters (the true limit is most likely 32767, which is the max value for a 16-bit signed integer, which is how script length is stored in the .esp).

Line Limit: there also is reportedly a maximum line limit. This seems to vary and reports on the forum range between 900-and 1500 lines of code. It's probably rather a limit of the compiled script than the actual lines of text, so empty lines and comments don't count. This is reported by an error message upon saving the script.

If-elseif limit: There is a limit on the maximum number of if-elseif conditions that can be used per script. I am not sure of the absolute number (I heard both 127 and 256). Also there is a maximum depth of nested if commands, it's reportedly 10 (Note: Error message for exceeding the maximum depth of nested if's is "Max nesting of 10 exceeded on line XXX" - in this case, you'll need to break it up somehow.)

Instruction Limit: An If-block or While-block is limited to 255 compiled commands (per block, not per script). The limit is not on the number of lines (each line may end up as several commands when compiled), and blank lines and comments don't count towards this total.

Script Name Limit: TunaandCheese reported a limit to the length of the scriptname:
Your script's name should never go over 31 characters in length.


I'm currently making a mod that has, admittedly, a fairly large global script - in fact I have just now split it into 2 smaller scripts, but still I'm having this problem: I get an "EXPRESSION" error when I try to start a new game, with only my mod loaded. As far as I can tell there is nothing wrong with the script, and if I take any section out, it works, so I can only conclude that the problem I'm having is because of some sort of built-in limitation that I'm reaching.

However, I have less than 7000 characters and 300 lines - way less than the limits mentioned in MWSFD (and I'm not getting any errors when saving the script so it can't be a line limit - nor can it be a maximum depth nested if-statement, or a script name limit (the script name is 22 characters)). I have 50 if-else-statements, tops, and none of the if-blocks are particularly big.

I'm reluctant to post the script because I want aspects of the mod to be a surprise (lame, I know), but I was just wondering if anyone had any new information relating to limits of the script editor?

Thanks,

- Danjb
User avatar
David John Hunter
 
Posts: 3376
Joined: Sun May 13, 2007 8:24 am

Post » Fri Feb 05, 2010 8:59 pm

I would suggest you cut the script(s) down until you don't get the error. (Binary search style). That way you can find what the problem is.

Oh, given the language, sacrifices probably help.
User avatar
Cat Haines
 
Posts: 3385
Joined: Fri Oct 27, 2006 9:27 am

Post » Fri Feb 05, 2010 7:22 pm

Thanks for the reply.

After investigating further, I believe the problem is actually an undocumented error that was in fact to do with a particular section of my script, specifically the line:

if ( Player->GetSoundPlaying "scroll" == 1 )


From MWSFD:

Look in the sounds menu in the TESCS to find which Sound ID corresponds to a specific action. For instance "illusion cast" corresponds to the player casting an illusion based spell. You'll probably have to experiment a little. Note: for some reason the Sound ID "drink" causes an error, so no checking if the PC is drinking a potion.


Basically, I've been playing around with GetSound Playing as it seems quite poorly documented... and I believe the "scroll" sound has the same problem as the "drink" sound.
User avatar
Undisclosed Desires
 
Posts: 3388
Joined: Fri Mar 02, 2007 4:10 pm

Post » Fri Feb 05, 2010 4:41 pm

This may not be helpful, but when I get an expression error like that it most often results from an undeclared variable or one declared that for some reason the game doesn't recognize. Like capitalization doesn't match or a local variable that is too similar to a global variable. I know you're probably aware of that, but just sayin', eh?:)
User avatar
Symone Velez
 
Posts: 3434
Joined: Thu Sep 07, 2006 12:39 am


Return to III - Morrowind