#include
This declaration is used to load any external code libraries that might be needed by a script (any other *.nss file). It needs to be placed above any code that uses the functions which will be loaded, but it is generally good practice to place #include directives at the top of a script before any code.
Functionally an include file is copy and pasted into the script at the given #include location with Pragma once assumed. They're only copied once if included more than once (eg; by using multiple #include statements which themselves include the same file). Note there is a limit to the amount of times includes can be used, which was raised to 128 times in NWN:EE which should allow a large amount of include files to be now used.
Having deeply nested or chained includes - an include including an include that has another include - can also cause issues when you have more than 15 levels (the 16th #include causes an issue). It provides feedback to the tune of "ERROR: INCLUDE TOO MANY LEVELS" in the include file that has the 16th level of #include (17th level if the original file with main() in is included).
Usage
#include statements have only the file's name, surrounded by text qualifiers (double quote characters), without the file extension.
Since it is a compiler directive and not an actual code statement, a #include does not have a ending semicolon.
#include "NW_I0_GENERIC"
Compilation
Previously compiled scripts that use the recompiled include will need to be recompiled as well before showing changes.
From the Toolset, Build > Build Module is a quick way to recompile multiple scripts in this situation.
author: Ryan Hunt, editor: Lilac Soul, additional contributor(s): Lilac Soul