How to use the script compiler for Dummies
====================================
WARNING! KOTOR 2 TSL : XBOX and NON-AMERICAN/CANADIAN USERS:
there is a mistake in the nwscript.nss file included in the international and xbox versions of the game. If you want to be able to compile your scripts, you have to correct the error first. For more details, see This thread. (
http://www.lucasforums.com/showthread.php?s=&threadid=146472) This error would have been fixed with patch 1.0b. If it,s not, you can also download a ready to use fixed copy of nwscript.nss here (
http://www.starwarsknights.com/forumdl/nwscript.zip).
====================================
note: double clicking on nwnnsscomp.exe won't get you very far: you need to use a command prompt or a .bat file (see below) to run it. If you don't know how to use a command prompt, read this article to get you started:
http://www.pcstats.com/articleview.cfm?articleID=1723)
====================================
You have 3 options to compile your scripts:
Using Fred Tetra's nwnnsscomp.exe (
http://kotortool.home.comcast.net/nwnnsscomp103.zip)
Using HazardX script compiler (
http://www.megamods.de/_data/parts/dl.php?file=37)
Using Kotor Tool Kotor tools has a brand new script editor and you can compile with a single click - see the second post of the present thread.
Advanced users: you can also decompile scripts with HazardX's and Fred Tetra's Script compilers but don't expect to get a .nss file: you'll get byte code (this is another reason why modders should release their source code). Check Torlak's page (
http://www.torlack.com/index.html?topics=nwnnsscomp) to learn to decipher decompiled scripts, and more particularly, this document (
http://www.torlack.com/index.html?topics=nwndata_ncs) contains valuable info.
-----------------------------------------------------------------------
A. How to use Hazardx script compiler/decompiler:
NOTICE CONCERNING TSL: if you are using HazardX script compiler, make sure you have nwscript.nss in the same directory as nwnnsscomp.exe, nwnnsscomp.exe will use it -- otherwise it will try to read it from the KotOR1 scripts.bif using the registry as a guide.
- for more information, read the readme that comes with the compiler -
Method 1: (use command prompt)
1. Make a new folder anywhere on your PC or use the game Override directory and drop nwnnsscomp.exe along with your scripts (.nss files) and for Kotor 2, also add nwscript.nss in that folder.
2. Open a command prompt in that folder and to compile all the scripts in your folder type nwnnsscomp -v1.00 *.nss or, for a single script, type:nwnnsscomp -v1.00 my_script.nss
If you chose to open the command promt from the Start menu, make sure the path to the folder is correct. Example: nwnnsscomp -v1.00 "c:\program files\blahblah\blah.nss"
Note: all scripts need to use the -v1.00 switch when compiling with HazardX script compiler.
You will find a practical trick to easily get to a command prompt from Windows Explorer right here (
http://www.lucasforums.com/showthread.php?s=&postid=1555481) - now you have no excuses to fear the little black window ;)
Method 2: (make your own batch file)
1. Create a new folder called Kotor_scripts (or whatever you want) or use the game's Override folder.
2. Open notepad and paste the text :
NWNNSSCOMP -v1.00 *.nss
del *.ndb
pause
then save it as Compile.bat and put the new Compile.bat in the same folder as the scripts you want to compile.
3. Put NWNNSSCOMP.exe in same folder as the scripts you want to compile (in the folder Kotor_scripts or, as the case may be, in your Override directory)
5. Double click the Compile.bat file (You should see a black command prompt popping out and if the script has compiled successfully you'll see:Compiling: blahblah.nss
Total Execution time = 75ms (or whatever times it takes)
6. press any key to close the command prompt.
7 . Look into your folder where you initially put your scripts (Kotor_scripts - or if you used the Override directory, in the Override directory). You should now see the following files:
- blahblah.nss (you don't need this one anymore but keep it for reference purposes and include it if you upload your mod somewhere!)
- blahblah.ncs (this is the compiled script that you need)
Method 3: (pre-made .bat file)
1. Make a new folder anywhere on your PC or use the game Override directory and drop nwnnsscomp.exe along with your scripts (.nss files).
2. Download this premade .bat (
http://www.starwarsknights.com/forumdl/nsscomp.zip) file attached at the bottom of the present thread.
3. Unzip the .bat into the same directory as your scripts (.nss files) and the nwnnsscomp.exe file.
4. Double-click the .bat file or run it from the command line.
--------------------------------------------------------------------------
B. How to use Fred Tetra's script compiler/decompiler:
-for more possibilities and if you have only one game installed, see this thread. (
http://www.lucasforums.com/showthread.php?s=&threadid=145516)
Method 1: (use command prompt)
- Make a new folder anywhere on your PC or use the game override folder and drop nwnnsscomp.exe along with your scripts (.nss files).
For Kotor 2 TSL
1. For non U.S. versions of the game (everywhere in the world save USA and Canada): there is a syntax error in the nwscript.nss file. Fix that and put the corrected version of nwscript.nss into your KotOR 2:TSL's Override folder.
2. Open a command prompt in that folder and to compile all the scripts in your folder type nwnnsscomp -c -g 2 *.nss or, for a single script, type:nwnnsscomp -c -g 2 my_script.nss
If you chose to open the command promt from the Start menu, make sure the path to the folder is correct. Example: nwnnsscomp -c -g 2 "c:\program files\blahblah\myscript.nss"
For Kotor 1
- Open a command prompt in that folder and to compile all the scripts in your folder type nwnnsscomp -c -g 1 *.nss or, for a single script, type:nwnnsscomp -c -g 1 my_script.nss
(If you chose to open the command promt from the Start menu, make sure the path to the folder is correct. Example: nwnnsscomp -c -g 1 "c:\program files\blahblah\myscript.nss"
You will find a practical trick to easily get to a command prompt from Windows Explorer right here (
http://www.lucasforums.com/showthread.php?s=&postid=1555481) - now you have no excuses to fear the little black window ;)
Method 2: (make your own batch file)
1. Create a new folder called Kotor_scripts (or whatever you want)
2. Open notepad and paste the text :
- For Kotor 2:TSL: (note: this method cannot be used if you have a version of the game other than the American/Canadian version because of a syntax error in nwscript.nss)
@echo off
nwnnsscomp -c -g 2 *.nss
pause
(note: For non U.S. versions of the game (everywhere in the world save USA and Canada): there is a syntax error in the nwscript.nss file. Fix that and put the corrected version of nwscript.nss into your KotOR 2:TSL's Override folder before compiling)
- For Kotor 1:
@echo off
nwnnsscomp -c -g 1 *.nss
pause
then save it as Compile.bat and put the new Compile.bat file in the same folder as the scripts you want to compile.
3. Put NWNNSSCOMP.exe in same folder as the scripts you want to compile (in the folder Kotor_scripts)
5. Double click the Compile.bat file (You should see a black command prompt popping out and if the script has compiled successfully you'll see:Compiling: blahblah.nss
Total Execution time = 75ms (or whatever times it takes)
6. press any key to close the command prompt.
7 . Look into your folder where you initially put your scripts (Kotor_scripts). You should now see the following files:
- blahblah.nss (you don't need this one anymore but keep it for reference purposes - and include it if you upload your mod somewhere!)
- blahblah.ncs (this is the compiled script that you need)