Note: LucasForums Archive Project
The content here was reconstructed by scraping the Wayback Machine in an effort to restore some of what was lost when LF went down. The LucasForums Archive Project claims no ownership over the content or assets that were archived on archive.org.

This project is meant for research purposes only.

Scripting for a Puppet - Need Help

Page: 1 of 1
 The Doctor
08-06-2006, 3:23 PM
#1
Alright, this is generally directed at stoffe, but I'm hoping to get an answer from someone who's online at the moment.

In stoffe's tutorial for adding a puppet to the game, I've his a dead end - it mentions a script named st_ai_puppethb. I can't seem to find a script with this name, nor do I know how to create one - KOTOR Tool won't open the .nss scripts, so I can't edit the content of an existing .nss script. I don't even know if that would work, to be honest...

I've created the .utc file, and extraced the other scripts I'll need. What do I do from here?

The tutorial also mentioned a program called nwnnsscomp.exe script compiler. Where would I go about getting this program?
 Princess Artemis
08-06-2006, 3:53 PM
#2
The scripts you need for puppets are all on stoffe's puppet tutorial page, including st_ai_puppethb, in the blue boxes with the scroll bars. Copy them into Notepad, save them as an .nss, and use Kotor Tool's black TXT button to open up a text editor. From there you can load the .nss. Tell Kotor Tool it's a script for K2, and you'll be able to edit and compile it. First use Save As... and make sure you save it as the correct script--I've ruined a few scripts before because when you load a new script into Kotor Tool, it doesn't always remember that it's a new script...always Save as... before you compile a script.

Any run of the mill text editor can edit an .nss. Notepad works perfectly as a script editor.

To get the nwnnsscomp.exe, I think that's in the general tools post. Kotor Tool now has the ability to compile scripts--I believe it comes with a version of nwnnsscomp.exe, so you don't really need it seperately unless you want it.
 The Doctor
08-06-2006, 4:25 PM
#3
Thanks, I have the script created now. :)



How would I go about using the compiler in KT? I don't see anything under the tools option...
 Kha
08-06-2006, 4:42 PM
#4
Go in Tools->Text Editor
 The Doctor
08-06-2006, 4:45 PM
#5
Alright... I have another problem now...

I don't seem to have an nwscript.exe file... where would I go to get one?
 Kha
08-06-2006, 4:54 PM
#6
I'm a complete newbie in scripting... but there is a nwscript.ncs and nwscript.nss in
BIFs->scripts.bif->Script, Compiled and Script, Source

But a nwscript.exe I don't know. If it is a nwnnsscomp.exe I have one in my kotor tools folder...
 The Doctor
08-06-2006, 4:59 PM
#7
Too bad it's against the forum rules to distribute them... unless I get permission from Fred for you to send it to me or something??? I dunno...

As for the .nss and .ncs file... I have no idea if those will do anything. I'm a scripting n00b too...

EDIT: I don't beleive this... I misread it. I don't need a .exe. I need a .nss. Stupid Doctor...

Sorry for the confusion... and thanks Kha, for making me notice my mistake...
 The Doctor
08-06-2006, 5:10 PM
#8
Ok, once it compiles the script, where does it put the .ncs file? I can't find the one it created anywhere...
 Kha
08-06-2006, 6:13 PM
#9
When I open a .nss file and try to compile Kotor Tools asks where I want to save it. So I think before compiling you should save your script somewhere and when you compile it will asks, or save it in the same folder of your script.
 Princess Artemis
08-06-2006, 6:46 PM
#10
Ok, once it compiles the script, where does it put the .ncs file? I can't find the one it created anywhere...

As Kha said, it gives you an option to choose where to save the .ncs. Kotor Tool sometimes likes to have fun forgetting where you opened a file, so you may have to go back to the folder you put the .nss in. I find that's usually the easiest thing to do, keep the .nss and .ncs together until I'm ready to release the mod, when I would then seperate them and put the .nss in a Source folder.
 The Doctor
08-06-2006, 10:38 PM
#11
I know what I was doing wrong... I'M SO STUPID!

It doesn't save it when I heit the Compile button, does it? I have to go File>Save - like every other windows program.

Feel free to flame me. That wasn't a scripting n00b mistake, that was a computer n00b mistake.
 Princess Artemis
08-06-2006, 11:55 PM
#12
Actually, it does save when you hit compile. That's one of the things you have to watch out for--if the .nss filename hasn't changed, it will save OVER the .nss when it compiles.

For example, stupid thing I did when getting mixed up about that. I have two scripts, one called a_adddustil.nss, and on a_attondustil.nss. I load up a_attondustil.nss, but Kotor Tool doesn't show the load name. So when I hit compile, I accidentally saved it as a_adddustil.nss, overwriting it. D'OH!! Fortunately I had a copy of it somewhere else.

Or, another stupid thing. Load up k_003ebo_enter.nss, save, compile, all good. Then load a_next_scene.nss, compile...OOPS, forgot to Save as... first. Now it's saved over k_003ebo_enter and compiled as k_003ebo_enter.ncs.

So, to be on the safe side, if I'm editing a script I can't easily retrieve, I open it in Notepad first, and leave it open while editing in Kotor Tool just in case I screw up and save over it when I comile another file. That way, if you save over an .nss, still open and safe in Notepad and you can save the Notepad version and recover most of your work. (I did that a lot with a_next_scene and k_003ebo_enter because they're very similar and I needed to copy back and forth a lot.) It's a quirk with Kotor Tool that you have to get used to. Always, ALWAYS Save as... your .nss files before compiling (unless you know for a fact you're just tweaking the same script) because Kotor Tool will save the .nss and the .ncs at the same time when you hit compile. It'll save you headaches and it'll save you from pulling your hair out if you accidentally have to re-write a script because you compiled over it.
 The Doctor
08-07-2006, 12:47 AM
#13
Ok... so what exactly do I do, then? How do I avoid saving over the .nss file? Even if I keep a backup open, don't I have to change the .nss somehow in order to compile it, lest it saves over the .nss??

Too late to stop that headache...

Can I just Save As... and save it with the .ncs file extension, or does that not do anything?

... I'm so confused...
 RedHawke
08-07-2006, 1:03 AM
#14
Can I just Save As... and save it with the .ncs file extension?
No, the nss text file has to be compiled to the ncs file that the game uses. ;)

Also if you are worried about saving over a file why don't you just make a copy of the original nss files to another backup directory. I ususally have a folder named 'Backup' or 'Safety' which I copy any and all mod files I am working with. So if something grenades or doesn't work right I have fresh files that I can quickly restore. :D
 The Doctor
08-07-2006, 1:09 AM
#15
No matter what I do, KOTOR Tool always seems to save the compiled script over the .nss. If I try to change the name when I compile it, it gives me an error message saying it can't open the input file.

EDIT: Ok, I managed to save a compiled script... but it has no file extension. My computer regonises it only as a Type: File. Can I rename it to a .ncs, or does KT need to do that?

...

...

Ugh.
 RedHawke
08-07-2006, 1:16 AM
#16
Do you have windows set to show file extensions?
 The Doctor
08-07-2006, 1:19 AM
#17
No, it only shows extensions that it can't open without a File>Open command. But when I move the mosue over the file, it says Type: File. Not Type: ncs File, like I believe it should.

But when I rename the file __________.ncs, the computer recognises it as a Type: ncs File. Will this work in the game then, or no?

Since I'm really stupid, and can't seem to figure this out no matter what I try, would it be possible for someone to compile these scripts for me, then send them on over? I'll tell you which ones I need and everything, I just need some serious help here...
 RedHawke
08-07-2006, 1:31 AM
#18
Set windows to show all file extensions. This is part of your problem, you need to see them.

And no renaming a file won't work you have to compile them... Try this tutorial for compiling. (http://www.lucasforums.com/showthread.php?t=143681)
 The Doctor
08-07-2006, 1:40 AM
#19
Ok... how do I set windows to show all extensions?

I hope this is the last question I have... I'm sorry for being such a nuisance...
 Jackel
08-07-2006, 1:45 AM
#20
To see all file extentions you will need to go to:

My Computer - Tools - Folder Options - View
Then its under the "Files and folders" section (should be right there if you dont scroll the scroll bar at all.)

Uncheck the box "Hide extensions for known file types"

Hit apply, then OK and things like .txt .nss etc sill show up.
 RedHawke
08-07-2006, 1:50 AM
#21
*Snips my long winded instructions from post...*

Curse my slow fingers! :fist:

What Jackel said is fine and easier to do too! :D
 The Doctor
08-07-2006, 2:01 AM
#22
Thanks a lot guys. I'm sorry for being such a pain in the assets tonight.

EDIT: I'm guessing I'm supposed to uncheck the 'Hide extension for known file types' box?

Sorry Doc but your edit question is really funny!

Uncheck the box "Hide extensions for known file types"
:lol: :xp: -RH
 Princess Artemis
08-07-2006, 10:20 AM
#23
Yeah, that would let you see all file extensions. Especially helpful if you have a program that decided all .uti files were accossiated with it. ::shakesafist at Spybot S&D::

With file extensions firmly in view, take RedHawke's suggestion of saving .nss files in a saftey folder (I'm trying that next time!). Forget everything I said about Notepad, RedHawke's is much less confusing and much safer, too.

Anyway. When you load an .nss into Kotor Tool, it doesn't necessarily 'remember' what the file name is. Look along the top of the window--if it doesn't display a file name, you have to Save as... first, then compile, or, Kotor Tool will prompt you to save the .nss--if you go that way, either save it with a new name AND the .nss extention (Kotor Tool will still try to compile without the .nss extention but it'll complain and I don't know if those those files work), or save it as the .nss you opened. That will save the text in the Kotor Tool text editor as the .nss and create an .ncs with the same file name. If Kotor Tool displays the wrong file name along the top, you're in danger of writing over your .nss when you hit compile. That's why you have to be careful to Save as... your files before you compile them in Kotor Tool.

To break it down, if you use Kotor Tool's text editor to write a script, go to File, Save as... then save, say, example.nss. Then compile it and Kotor Tool will write over example.nss and create example.ncs.

Or, just go to compile, and you will be prompted to save the file. Save as example.nss, and Kotor Tool will save the text as example.nss and compile example.ncs.

If you open a file in Kotor Tool, edit it, and go to File --> Save as..., then click on the .nss you opened. Always do this every time you open another .nss before you compile because of the quirk in Kotor Tool that causes it not to remember the correct name of the file.
 The Doctor
08-07-2006, 1:15 PM
#24
It's still not creating any .ncs files.

I'm going to explain what I'm doing step by step, using k_inc_drop.nss as an example.

I open k_inc_drop.nss with the text editor.
I go File>Save as...
I save the file as k_inc_drop.nss
I tell KT that the script is for KotOR II, and hit Compile

When I go to the destination folder, there's no .ncs file there. Just the .nss files I have in that folder.

What am I doing wrong?
 stoffe
08-07-2006, 1:20 PM
#25
It's still not creating any .ncs files.
I open k_inc_drop.nss with the text editor.
I go File>Save as...
I save the file as k_inc_drop.nss
I tell KT that the script is for KotOR II, and hit Compile
When I go to the destination folder, there's no .ncs file there. Just the .nss files I have in that folder.
What am I doing wrong?

As the _inc_ part of the file name indicates, k_inc_drop.nss is an include file. You cannot compile an include file since it's not a complete script. Include files are just a collection of functions and/or global variables that are meant to be used in other NSS script source files.

Thus if you modify an include file you will need to recompile all scripts that use this include file instead (I.e. script that have the #include "k_inc_drop" directive somewhere in their source code.)

Only scripts with a starting point function (main() in all scripts except dialog conditional scripts which use StartingConditional() as starting point function) can be compiled. NSS files without those functions serve as include files, containing script code that several other "real" scripts may use. :)

A script and all used functions from include files (along with all global variables declared) are packed together into the NCS file when you compile them. An #include directive essentially just tells the compiler "copy and paste the content of this file here before proceeding with compilation". :)
 The Doctor
08-07-2006, 1:31 PM
#26
So the only scripts I need to comile are the two you gave in your tutorial, then?
 stoffe
08-07-2006, 3:12 PM
#27
So the only scripts I need to comile are the two you gave in your tutorial, then?

Yes that should be enough. The include files listed are just needed in order to compile the posted script. They are part of the creature AI that are included since you modify one of the AI scripts for the puppet (the Heartbeat script).
 The Doctor
08-07-2006, 3:15 PM
#28
Again stoffe, you're my hero.

Thanks everyone, both for trying your best to help, despite my stupidity, and for repeatedly re-iterating your instructions to help me understand. Thanks.
Page: 1 of 1