Neverwinter Nights Enhanced Edition Script compiler - Based on Skywing Parser enhancements
>>> For newer releases see this github page: https://github.com/nwneetools/nwnsc <<<
*** UPDATED VERSION 1.0.0 ***
Since the game has gone gold and the compiler has been stable this is the 1.0.0 release. It fixes a few small bugs and adds some compatibility updates with the latest Toolset compiler.
This is a nwscript compiler based on the Skywing Compiler engine NWNScriptCompiler that was adapted from Edward T. Smith's nwnnsscomp now updated to work with NWN EE.
Changes - 1.0.0
Added the ability to parse and compile escaped double quotes (\") in strings based on the latest nwscript changes. This will default to on and may cause compilation issues with older scripts until they are updated. The compiler switch -Q was added to disable this feature and revert to the previous behavior. The parsing of double quotes is also disabled when compiling for 1.69.
Updated the Makefile compatible dependency files to only insert includes that are in the file system and ignore the entries in packed .bif files.
Fixed a Linux / Mac crash when illegal characters were detected in a file
Fixed a crash when freeing memory when parsing arrays
Changes - 0.9.7
Added -l command for compiler to automatically locate the game install folder (see help for details)
Fixed file handle leak on Linux / MacOS - (reported by BhaalIM)
Eliminated the logs folder creation
Clean up of output and -w flag to suppress warning display
Control-C on Linux / Mac will no longer abort and dump a stacktrace
Fixed error when compiling for NWN Diamond - version 1.69
Changes - 0.9.6
Fixed several null pointers and segmentation faults
Improved speed with compile optimizations
Redundant -l command line option not required when passing -n
When building for NWN EE the installdir ovr folder (override) will be processed for includes before the .bif files
Added -M to create Makefile compatible dependency files
This has been tested to work with both NWN EE (1.74) and NWN 1.69.
Source Code and Issue Tracker: https://gitlab.com/glorwinger/nwnsc
SS(link is external)
Installation
Unpack the binaries from the zip file and place them somewhere in your path.
Check the following requirements
Windows - This has been tested on Windows 7 and Windows 10. Please report issues.
MacOs - This has been tested on MacOs 10.10 and 10.13. Please report any issues.
Linux - This has been statically linked and should run on the following
Debian >= 6
Ubuntu >= 10.04
Red Hat Enterprise Linux >= 5
CentOS >= 5
Using nwnsc
Usage message
Usage: version 0.9.7 - built Mar 18 2018 14:32:17
nwnsc [-degjklorsqvwyM] [-b batchoutdir] [-h homedir] [-i pathspec] [-n installdir]
[-m mode] [-x errprefix] [-r outfile] infile [infile...]
-b batchoutdir - Supplies the location where batch mode places output files
-h homedir - Per-user NWN home directory (i.e. Documents\Neverwinter Nights)
-i pathspec - Semicolon separated list of folders to search for additional includes
-n installdir - Neverwinter Nights install folder. Use to load base game includes
-m mode - Compiler mode 1.69 or 1.74 - (default 1.74)
-x errprefix - Prefix string to prepend to compiler errors (default "Error")
-d - Disassemble the script (overrides default compile
-e - Enable non-BioWare extensions
-g - Enable generation of .ndb debug symbols file
-j - Show where include file are being sourced from
-k - Show preprocessed source text to console output
-l - Load base game resources - not required with -n
-o - Optimize the compiled script
-p - Dump internal PCode for compiled script contributions
-q - Silence most messages
-r - Filename for output file
-s - Enable Strict mode. This enables stock compiler compatibility that allows
some potentially unsafe conditions (default: off)
-v - Version and detailed usage message
-w - Suppress compile warnings (default: false)
-y - Continue processing input files even on error
-M - Create makefile dependency (.d) files
- Q - Disable the parsing of \" (added in NWN EE build 8176)
The Compiler requires the nwscript.nss from the game resources. The following order
will be followed to find the file. The search stops on the first match.
1. -i pathspec The pathspec will be searched as the game scipts may
be unpacked into a flat folder structure
2. -n installdir will be searched. The search starts with <installdir>/ovr
and continues with <installdir>/data/*.bif files
3. -l If the -l flag is passed The following sources are searched:
Check the environment variable NWN_ROOT
NWN EE Digital Deluxe Beta (Head Start)
NWN EE Beta (Head Start)
NWN EE Digital Deluxe
NWN EE
NWN Steam
Optional debug flags
-D - Set Debug Log level
-I - Set Info Log level
-W - Set Warning Log level
-T - Set Trace Log level
Portions Copyright (C) 2008-2015 Skywing
Portions copyright (C) 2002-2003, Edward T. Smith
Portions copyright (C) 2003, The Open Knights Consortium
Adapted for Neverwinter Nights Enhanced Edition and cross platform use by: Glorwinger and Jakkn
Examples
Compile a folder of scripts for NWN EE without extracting game files - Compiler will find Game folder as above
nwnsc -l *.nss
Compile a folder of scripts for NWN EE without extracting game files
nwnsc -n /Applications/Beamdog/00829 *.nss
Compile a folder of scripts for NWN EE using extracted game files in a flat foldernwnsc -i ../../tmp/bif/base_scripts.bif *.nss
Attachment | Size |
---|---|
![]() | 4.34 MB |
![]() | 280.62 KB |
![]() | 571.86 KB |
Thank you for this, Glorwinger.
Thank you!
Full marks :)
For some reason, when I double-click the .exe, nwnsc just flashes for a split second, and then disappears? I'm using NWN:EE but moved to my D: drive from documents. Also, I'm on Win7 pro 64 bit.
That's because it is a command line compiler. You'll either need to create some batch files or launch the command prompt to use it. In other words there's no sign of a problem from your description. Just you didn't realise how it needs to be used.
TR
This is true, TR, and thank you for the instruction. Oh, and btw... Thank you a TON for your FANTASTIC tutorials on scripting! I can't wait to begin to try and teach myself how to do that with them... Finally make a module that even has a spot of life in it :P
Back on topic, I do appreciate your help and am off to go try it.
-e - Enable non-BioWare extensions
What are these extensions? The windows zip file didn't have any documentation, it just contains nwnsc.exe.
Thank you! This is a huge time saver.
Hi All and Hi Glorwinger! Could you possibly point me in the direction of how to use this compiler? I dont have a programming background so I am fumbling around a bit here. But I seem to be making my way through the weeds. Currently, I have the mod open with the scripts I want to compile and I managed to download this program and create a .cmd file with the following instructions:
@ECHO OFF
The project is now maintained here:
https://github.com/nwneetools/nwnsc
Recent release, v1.1.1 with fixes: https://github.com/nwneetools/nwnsc/releases/tag/v1.1.1
Finally got around to trying this and it is a great time saver when used with the new NWN:EE development folder.
I've encountered a strange issue wth some unhelpful error messages.
My Grimoire project builds just fine with nwnnsscomp. When I try to use nwnsc, I get these errors:
Compiling: gr_client_oce.nss
GR_IC_DOMAINS.nss(18): Error: NSC1045: Variable "DOMAIN_WAR" defined multiple times in the same scope (previous definition at nwscript.nss(5967))
GR_IC_DOMAINS.nss(18): Error: NSC1046: Identifier "DOMAIN_WAR" is already defined at nwscript.nss(5967)
The line at 5967 in nwscript.nss is:
void PrintObject(object oObject);
That domain constant and others that are throwing errors are only defined in one file (GR_IC_DOMAINS). The nwscript.nss I extracted from base_scripts.bif doesn't have them defined as denoted by the messages. I even tried the -i argument with nwnnsscomp to point to the extracted EE nwscript.nss file to see if that triggered some type of error and it did not. I've gone through my includes and there are no circular references.
Any thoughts on what I might be doing wrong, or is there something else going on?
EDIT: so apparently my age is showing - if I use the -m 1.69 switch, it works fine. I didn't see a primer/tutorial on the Lexicon site for old dogs like me on how to update 12 to 14 year old scripts from 1.69 to 1.74. Is there some form of documentation somewhere that I haven't been able to google-fu yet?
Please disregard the previous comment. With some assistance from another forum I was able to figure out the issue.
Is there a version of this that works with PRC scripts?