before I get into scripting, I want to make clear that I am not a programmer by trade. I am only a "hobby-grammer". I feel this is good for the novice scripter because I won't boggle your mind with a bunch of technical terms and programming lingo. If any "pros" out there would like to correct me on any explanation I may present with the correct terms, please feel free to do so and I will add a Editors note to the "technical" side of the issue. My real profession is Electronics and electrical engineering. This in many ways is similar to programming and both operate on simple logic.
NWN1 and NWN2 scripting is a small but powerful tool that can be used in the toolset to create almost anything imaginable, new spells and effects, traps, custom rules, you name it. What you can do in the toolset is largely dependant on your own imagination. There are some things that just can not be done, but about the time I say that - someone will prove me wrong by doing it. If you want more power at your fingertips to control the aspects of your Module, Multiplayer, or PW, then learning to script is essential.
One thing that makes scriptinga bit easier to understand is first learning to "read" a script, as you would read a paragraph. Here is a small example;
I want to;
"Capture the Entering object of this area. If it is a Player Character, I want to apply a Damaging Effect to the Player for 10 hitpoints. Then Send a message "You are too cold" to the player."
Reads simple enough right? Now lets look at the exact same paragraph written in nwscript, then we we look at how the 2 relate.
object oPlayer = GetEnteringObject();
effect eDam = EffectDamage(10);
SendMessageToPC(oPlayer,"You are too cold");
Now lets read the script. Bold words are straight from the script above.
The Object oPlayer is equal to the entering object. If the object oPlayer is NOT (!) a PC character, exit (return) the script. Effect eDam is equal to 10 points. Apply this effect INSTANT to the object oPlayer. Send a message to object oPlayer of "You are too cold".
Can you see how the two relate? Read it over a few times and try to match the lines in the script to the sentences in the paragraph above. Soon it will click and make senses. Don't worry about what every thing means at this point, simply try to relate the script to the bold words in the paragraph. We will cover what the "if" and "effect" and "!" mean later on.
Congratulations - you just learned how to read another language! It may sound a bit odd, but trust me - knowing how to read a script will help you to construct your thoughts such as this;
"I want to loop the players inventory and count how many items the player has"
into code such as this;
int iNum = 0;
object oItem = GetFirstItemInInventory(oPlayer);
oItem = GetNextItemInInventory(oPlayer);
I will be referring to this throughout these lessons.