Nwnsc usage - help needed

#1

Hey guys, I’m in desperate need of some help here. I’ve been struggling with compiling a bunch of scripts using nwnsc tool and I’m about to slice my wrists :frowning: I have no idea how my .bat file should look like.

I’m on Windows, NWN:EE, steam version.

nwnsc.exe is placed in my game folder:
'C:\Users\MYUSERNAME\Documents\Neverwinter Nights\
I’ve created nwnsc.bat file in the same directory as above.

My scripts are placed:
'C:\Users\MYUSERNAME\Documents\Neverwinter Nights\modules\scripts
in separate subfolders, e.g.:
\scripts\includes\
\scripts\spells\
\scripts\feats\
etc.

Anyone here familiar with this tool and could help me out with the content of that .bat file to make it work?
I’d be grateful for your time and patience.

0 Likes

#2

Something like that should work.

@echo off
setlocal enabledelayedexpansion
color a
echo Please wait...
cd "C:\Users\MYUSERNAME\Documents\Neverwinter Nights"
for /r "%~dp0\modules\scripts" %%f in (*.nss) do (
color a
echo Compiling "%%f"
nwnsc.exe -i "modules\scripts\includes" -o "%%f"
)
pause
1 Like

#3

Still getting an error :frowning:

Compiling "C:\Users\MYUSERNAME\Documents\Neverwinter Nights\scripts\spells\MYFILENAME.nss" 'nwnsc.exe' is not recognized as an internal or external command, operable program or batch file.

Same log for every .nss file.

0 Likes

#4

Sorry, my bad. I corrected the batch script.

0 Likes

#5

Thank you very much! :heartbeat:

Got one more question. Hopefully the last one. Do I have to put every include script in ‘includes’ folder? Is there any way to make the compiler somehow check for those default game scripts wherever they are in installation folder?
I mean those base scripts like x0_i0_campaign.nss etc., that I don’t have to manually grab and compile in toolset, when I’m compiling my scripts there.

0 Likes

#6

You’re welcome!

No, you don’t. Try to play with the rest command-line arguments for NWNSC, they all are listed on the project’s page:
https://neverwintervault.org/project/nwnee/other/tool/nwnsc-nwn-enhanced-edition-script-compiler

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”)

So in my example replace

nwnsc.exe -i "modules\scripts\includes" -o "%%f"

with

nwnsc.exe -i "modules\scripts\includes" -n "full path to the game root directory" -o "%%f"

"full path to the game root directory" = "C:\Games\Neverwinter Nights Diamond", for example.

1 Like

#7

Heck yea, finally got it! Appreciate your help, u’ve just saved me hours and hours of time!

1 Like

#8

@Aqvilinusgot one more question - is it possible to compile includes? It keeps skipping include scripts.

0 Likes

#9

No, *includes* cannot be compiled technically by themselves (and there’s no reason to compile them at all), they don’t have the entry point - the main() function. You can only attach them to the actual scripts with the main() function.

…but there’s a small trick, if you want to check your includes for errors before using them as includes: add temporarily the empty main() function into them and then try to compile them. If there’re any errors, compiler will tell you about that. If an include compiles successfully, comment out or remove those empy main() function statements (otherwise you will get an error if you try to use such include in the actual script).

void main() {}
1 Like

#10

Noted! Once again, thanks for your help and patience :wink:

0 Likes

#11

tip2 – put void main(){} as the last line in the #include to ensure that the parser parses all lines in the file

0 Likes