PDA

View Full Version : How to compile scripts?


Darth333
01-31-2005, 12:55 PM
How to use the script compiler for Dummies * (*note: I was part of the "Dummies" too at some point - maybe I still am - so this is why I wrote this tutorial)

====================================
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://web.archive.org/web/20050320194731/http://www.torlack.com/nwndata/ncs.html) 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)

Darth333
01-31-2005, 12:56 PM
Compiling scripts with Kotor tool:

Before anything else, make sure you have enabled the view extensions option in Windows. If you haven't, open Windows Explorer and go to the Tools menu > Folder Options> View and uncheck "Hide extensions of known file types" and click OK.


1. Go to the tools menu
2. Select the text editor.
3. Then in the text editor window, go to the script menu, select your game (kotor 1 or kotor 2)
4. make your script, save with a .nss extension.
5. Either go to the script menu and select compile or simply press F5
6. The compilation should output a .ncs file.
7. Drop the .ncs file in the override folder (or pack it into a .mod file if you are creating a new module)
8. (optional but strongly recommended) If you distribute your mod, please include the source code (*.nss files) in the download package so others can see how it was done (that's how the Holowan labs forums were built: sharing info on modding) :)


Compiling scripts on a machine that doesn't have Kotor installed

Download NWNSSCOMP port for KotOR Script Compiler (http://www.starwarsknights.com/tools.php#sct) by stoffe and tk102.

Drop it in the same folder as your scripts and use:
nwnnsscomp -c myscript.nss

or for several scripts:
nwnnsscomp -c *.nss