ok, a couple of problems there. First you have never declaired what type of varaiable oItem is. You have to explicitly tell the compiler what type of data a varaiable holds before you can use it.
here is a list of the data types usen in NWScript.
Data TypesNow if you have that script in the script editor and double click on SetCustomToken you will get some help information at the bottom of the screen for how the function needs to be implimented.
It will show this.
// Set the value for a custom token.
void SetCustomToken ( int nCustomTokenNumber, string sTokenValue
The colored parts I will explain a little better.
void The only thin this first void says is that the function does not return any data to the calling code. If the function did return data to the calling code It would be the Data Type of the Data returned.
SetCustomToken this is the lable the function is know by. Just like any Lable/Variable It has to have a data tye associated with it. In this case it is a Void, meaning that is does something but does not return any data to the calling code.
nCustomTokenNumber and
sTokenValue are the Arguments to the function. Thies are the lables that the function will use internaly for the data that you pass to the function. The actual lables are meaningless but are comonly given names to help the user understand what type of data the function need passed to it.
int and
string are the Data Types that the function expects to be passed to it for the Arguments. So
nCustomTokenNumber has to be of data type
int and
sTokenValue has to be of type
stringNow before I get back to your script. Let me comment on the 'o' in oItem. it is a common practice to have a
Naming Conventions in place when writting a script. The Conventions are not enforced by the compiler. They are just rules set in place and followed by the scripter to make there ability to read the code easier. By the Conventions adopted by most NWN Scripters the 'o" in front of your oItem lable would tell then that it is a varaiable/Lable for an object.
Since your script looks like it is just trying to set the custom token with a varaiable the has to be a string, I would suggest changing the name to something like sItemName. and declare it towards the begining of the script with: string sItemName;
Also you are currently setting this varaiable to the ResRef's of the items. That is not what you want. you should change them to the names you want the custon token set to, "bread", "Milk" and so forth.
Modifié par Lightfoot8, 26 novembre 2011 - 07:44 .