7. Scripting
One of the major reasons for creating MWEdit is to improve the ease of creating and debugging scripts which are probably one of the most difficult aspects of plugin creation. A completely new script compiler has been created from scratch which records many more error messages and warnings than the TESCS compiler. An error message will prevent the script from compiling successfully while a warning message will not (although the compiler script may not work as expected). Some of what the new compiler checks include:
- Object types used in functions are checked more rigourously. If the function expects an NPC ID, you'll receive an error/warning if you use another type.
- Functions that are known to be broken will result in a compiler message.
- Compiler does not permit the use of reserved words as local variables (such as END, X, Y, etc...).
- Required spaces in IF and SET statements (spaces are added if missing)
- Checks for missing or extra function arguments.
- Does not allow the use of multiple objects references on one line.
- Checks the number of buttons/variables used in the MessageBox function.
- Warns for missing function commas.
- Warns for local/global ID conflicts.
- Checks if the function accepts variables or not.
- Checks maximum length of variables, IF, SET statements, etc...
- Checks for unknown or incorrect syntax.
When you compile a script, all warning and error messages are displayed in a splitter list at the bottom of the script window. You can double-click a message to jump to that point in the script where the error occurred, or right-click the message to display more options such as viewing details of the message including any function information if available. There are three levels of recording warning/error messages:
Weak,
Default, and
Strong, allowing you to set how many warning/error messages are recorded during a compile.
The script text is color coded which allows you to easily identify functions, numbers, keywords, etc... A default white or blue color scheme is available or define your own custom colors which are saved in the registry. The color formatting can also be disabled. The font used in the script window can also be selected.
Complete help on all the script functions is available from the help menu. The help describes all the function parameters, the return value, and function description as well as any special function notes (such as whether it is a Tribunal function, etc...).
Other script commands include the ability to export and import scripts to/from text files and the compiling of scripts on save automatically (no warrning/errors displayed). The Import/Export option is available from the
File menu. Exporting a script will output the entire script(s) to a text file with the same name as the script (existing script files are overwritten). When you import a script the script name will be taken from the script name within the file (i.e.,
begin scriptname).