Preprocessors
From NWN Lexicon
Jump to navigationJump to search
As of 1.89.8193.37 (and newer versions of nwn_script_comp) these preprocessor instructions below help debug your code.
They act similar to constant string variables (except __LINE__) insofar as they can be concatenated into a normal string variable as per the example.
However unlike some preprocessors they cannot be included as default function parameters.
List of Preprocessor Macros
| Macro Name | Description and Notes |
|---|---|
| __FUNCTION__ | The current function name. eg: "main" if in void main() |
| __FILE__ | The current file name, including extension eg: test_file.nss. Note to get this with no extension you can just use GetScriptName. |
| __LINE__ | The current line. Integer. |
| __DATE__ | The current date at compilation. Format: YYYY-MM-DD |
| __TIME__ | The current time at compilation. Format: HH:MM:SS (24 hour clock) |
Example
void main()
{
// Debug the line
SendMessageToPC(GetFirstPC(), "Function: " + __FUNCTION__ + " file: " + __FILE__ + " line: " + IntToString(__LINE__) + " date: " + __DATE__ + " time: " + __TIME__);
}
Example output if filename is test.nss:
- Function: main file: test.nss line: 3 date: 2025-10-04 time: 22:25:04
Version
This primer was added in 1.89.8193.37 of NWN:EE. scriptcomp: Added support for __FUNCTION__, __FILE__,__LINE__, __DATE__ and __TIME__.