MSFD Error messages, malfunctions and common causes
In the editor
The editor usually indicates the line in which the problem was encountered, so often errors reported here are relatively easy to fix.
"Mismatched If/else/endif starting on line..."
One or several if statements are not closed. Use tabs to facilitate finding missing endifs. This also happens when wrong names are used for variables functions or other typing errors.
"Function reference object "Foobject" not found"
This error indicates that the object in question e.g.
Foobject->GetDistance Player
Does not exist. When you write a script and then create a new object to be thus referenced you will also get this error. Close the editor window and reopen it to register the object with the compiler.
"Could not find variable or function "Foobject""
Another syntax error, indicating you have used an undefined variable, function or a non-existent object.
"Script command "foofunc" not found on line 3"
A command / function was not recognized by the compiler. Usually results from typos.
"You need to end a script with script End scriptname"
Indicates that the compiler did not find the End command. This error can also appear when a previous error disrupts the compilation process.
"Syntax error Line 20. Miss matched parenthesis"
Indicates that you do not close all parentheses you opened or vice versa.
"You need to enter a value on line 20"
You have not supplied all the arguments needed by a specific function.
In game error messages:
"EXPRESSION in script..."
Followed by
"RightEval ..."
This error indicates that Variables are not declared. Most often this happens with game variables that are almost used like functions, e.g. OnPCEquip.
EXPRESSION in general appears mostly when variables have not been declared in the script.
"LeftEval"
This error seems to come up when you have accidentally declared a Function as a variable. The following lines e.g. would produce this error:
short ScriptRunning
if (ScriptRunning "MyScript" == 1 )
Both of the above can also be caused by not having spaces at the proper places. Always leave a space between parentheses and function calls, variables etc.
If ( OnActivate == 1 ), not if (OnActivate==1). This only causes errors very rarely, but it sometimes does, trust me.
"Infix to Postfix" error
Usually indicates bad syntax. Can be caused by bad set commands using the "fix" arrow:
set somevar to ActorID->GetHealth
should be changed to:
set somevar to ( ActorID->GetHealth )
An alternative is again a forgotten variable declaration of variable type functions, e.g. of OnPCEquip, etc. (Thanks Horatio and Ragnar_GD)
AITravel command does not work
A common cause is coordinates erroneously set too far away (e.g. by omitting a "-" or having a digit too much in there). I once had a very nasty one of having typed two "-" which looked like one just slightly longer than usual "-" in the editor.
Doubled Objects
There are two reasons why you may get doubled items in your game
1. You changed your mod load order (or added a mod in the middle of the load order) and then continued on from a save. This is very easy to do accidentally by just saving a mod in the CS, which will move the mod in the load order.
2. You altered a object that had information about it stored in the save or Added/removed a object that is in the same cell as a object with information stored about it in a save.
The best way to prevent doubling when testing work in progress mods is to always test a mod on a save that doesn’t have the mod loaded or even better a new game.
Wrye has notes on these in much greater detail http://wrye.ufrealms.net/Wrye%20Matching.html
Script fails to start, or stops unexpectedly
This can happen when a variable is not declared but the script was nevertheless successfully saved, for example if you deleted a variable declaration or changed the variable name after saving and didn't update it correctly in the script. It can also be caused by the same thing in another (different) script.
Crash to desktop when executing the script
There are unfortunately a great number of possible causes. Many are connected with not having "do once" conditions (e.g. calling certain functions every frame). Other known problems: Removing objects with running scripts from within their own script. Using Equip on anything but potions (fixed with Tribunal). Casting targeted spells from an activator (fixed with Tribunal). Using AIActivate on teleport doors that lead outside of the active cell. Trying to use PlaceItem with the same Object ID the script is running on. Using SetDelete on a non-disabled object or an object with a targeted script running on it.
Crash to Desktop (CTD) upon loading the plugin
One reported reason is overlong calculations: there appears to be an issue with very long additions (e.g. adding up more than 20 variables in one line of code) that causes a mod to CTD upon loading. If this happens, split the calculations to several lines.