One of the best ways to learn a new programmign language is to be able to see the results of your coding. It is the purpose of programmign to have teh computer do somethign you want. In the NWN2 system, the purpose of coding is to have the game do something you want. In this section you will discover one method of seeing how your pogram affects the NWN2 game.
Getting into the NWN2 Editor
The first thing to do is to get into the NWN2 editor and then do the following steps:
Create a new module and save it as Program1
Create a new scripts and palce the following code into it:
Be sure to copy the code exactly as shown. Note tha ttwo of the lines end in semicolon ;.
Remember that C++ code is case sensitive so make sure each letter in your new code is exaclty as shown above.
Compile the program (F7)
If there are no errors, this will be automatically be saved as Script1.
Create a new area.
Once the new area is created, place a trigger on it.
Go to the Blueprints windows.
Select Triggers.
From the resulting selections, select Empty for the trigger type.
From the resulting seletions, select NewGeneric.
Your mouse arrow will change to a crosshairs, click on 4 different points in front of the Start symbol in your new arena. This will create an orange rectangle.
Go to the third menu bar at the otp and click on Select Objects.
The mouse now changes back to an arrow.
With the mouse, select the orange trigger area you just created, click on it, a green area will appear, then right click and a pop-up menu will appear.
From the pop-up menu select Properties (new window)
In the resulting Properties window under the Scripts area select the on Enter Script.
In the box just to the right of the On Enter Script, type in the name of your new script, which by defualt is Script1.
Go to the File menu and Bake the area.
Save and Exit the NWN2 Editor.
Open the NWN2 game.
Select New Game.
Select New Module.
Select your saved module Program1
Select Select Character
Pick any character you wish
Once the game screen comes up, move your character (PC) over the trigger area you created.
Observe that the text: Hello NWN2! now appears over the PCs head.
Observe that the same text also appears in the message box in the lower left of your screen.
Every time you move your character over that area, the message will appear.
Making Things Simple
You don have to go through all of the above steps every time you make a new program. You only need to go into the editor, and call up your Program1 module. Now all you need to do is to modifty your Script1 and see the results in the NWN2 game.
Nwn2Scripting provides material for training only. We do not warrant the correctness of its contents.
The risk from using it lies entirely with the user.
While using this site, you agree to have read and accepted our
terms of use and
privacy policy.
Copyright 2008 by Adamson House, Ltd. All Rights Reserved.