The script editor in NWN1 and NWN2 are unfortunately not the same. I will cover some of the differences here.
The NWN1 Editor:
The NWN2 Editor:
As you can see, there is a big difference between the 2 editors. On of my favorite is colors. I have set the NWN1 editor to my liking, but I can't set the same colors in the NWN2 editor. Also, the Save, Open, Close, and SaveAs features are gone in NWN2. This is a bit of a pain because in NWN2 you must Compile the script, then rename the file in the script list palette. Also, the NWN2 editor is missing the Help, Bookmark, and Search Results tab at the bottom, as well as the Variables and Templates button (NWN@ has "Globals" which is the same as "Constants" in the NWN1 Editor. The templates button I will really miss as I had a lot of templates that I could just insert into a script and fill in the blanks. Now in NWN2 I must re-type everything each time I make a script using the same format. NWN2 also does not open with the default "void main()" beginning. Aside from these differences, the two editors are essentially the same. I will speak "in general" on using the script editor, it will be up to you to keep these differences in mind.
Using the script editor:
There are 3 type of code that you can write in the script editor. A Script, an Include file (or custom functions), or a Starting Conditional for a conversation file.
Scripts:
All scripts start with void main() what this means will be covered later - just remember that if there is no void main(), then it's not a script but rather a starting condition, or an include file.
Include Files:
An Include file is a list of custom functions, predefined constants or variables, or possibly all of the above. When you see the term #include "some_file" at the top, it is simply telling the script to "include" something defined from the file "some_file". This is not a script per-say, and they don't compile as a void main() would. More on Includes later.
Starting Conditional:
A Starting Conditional is a special type of script that returns TRUE or FALSE to something else. In the case of NWN, the conversation file for the "Text Appears When" condition. This is what determines whether a text line is displayed in the conversation. Scripts of this type start with int StartingConditional()
The two most important tabs in the script editor is the functions and Constants tabs. These list all of the functions and constants available to you when scripting. The filter box is a great asset as well, this helps you locate the function you are looking for. For example, if I need a function so I can get the name of an object - but can't remember what that function called we can enter the term "name" in the filter and all function with the term "name" in them will be displayed - hiding all others. You can then double click on the function to insert it into your script. This makes it handy when looking for a function your not sure even exist, you can type in a term that you think it might have in the function name to see if any relate - which brings us to the help or notes tab. when selecting a function from the list, any comments about using the function will be displayed in the window at the bottom. This will help identify if the selected function is the one you need.
Open the script editor now and type "Attack" in the filter box. All function that have the word attack in it will be displayed. Now select each function listed and view the comments. try other words or part of word as well, see if you can find functions you didn't know existed. It would also be a good idea at this point to familiarize yourself with most of the functions. If you not sure what a function is, not to worry - those will be covered soon enough.
The Global's or Constants tabs work the same way as the functions tab. There is also another way to look up a function. Click anywhere in the script editor and type the word "Get", now press "F2". You will see a window open with the function list and the first highlighted word is Get... you can scroll down the list and select the one your looking for and it will fill in the rest of the function for you. Note: Unfortunately, Obsidian nixed this in NWN2 as well.
Save your script and give it a name. any script errors will show in the Compile window alerting you as to what might be wrong. Errors will be covered later on, but just know that if you get errors in this window, the script won't function.