Custom tokens
From NWNWiki
Creating a custom token is easier than one might think. A custom token is simply a number representation of a string, analogous to the Constants in nwscript. Here is a simple "follow along" tutorial for custom tokens.
- Make a conversation on a NPC like the following,
+Root
1 - NPC: "Hello"
2 - ..PC: "What is your favorite Color?"
3 - ....NPC: "My Favorite Color is <CUSTOM2000>"
- Save the file and and attach it to an NPC.
- Place the following script in the "Actions Taken" of Line 1. This will set up the custom token for you, choosing a random color.
void main()
{
switch(d4())
{
case 1: SetCustomToken(2000,"Red");break;
case 2: SetCustomToken(2000,"Blue");break;
case 3: SetCustomToken(2000,"Green");break;
case 4: SetCustomToken(2000,"Yellow");break;
}
}
Now, when Line 3 is spoken, either Red, Blue, Green, or Yellow will be spoken in place of the <CUSTOM2000>.
Some points to remember:
- Custom tokens, once set, will remain set until changed, so be sure to set them up before you need them.
- Custom tokens will work in the names of placeables, but not NPC names, or item names.
- Custom tokens do not work in the descriptions of placables.
