It seems that you're using an outdated browser. Some things may not work as they should (or don't work at all).
We suggest you upgrade newer and better browser like: Chrome, Firefox, Internet Explorer or Opera

×
Sorry, the NWN builder forum was down and I thought I'd ask this here just in case anyone here is familiar with the toolset.

I've been working on a module off and on for awhile now. In my module there is a journal in the starter chest that you can pick up and read that acts as part of the introduction to the story. I want to add the Player Character's <firstname> as a token into the book so that it ties the player into the events taking place in the journal. I can't get it to work, and the book just says <FirstName> or <PlayerName> or whatever token I attempt to insert.

Is there a way to add the PC's name into the book, or do I have to figure out how to make it work without tying the player's name into the narrative?

Just to be clear, this is a book I created in the Item Wizard and not part of the player's actual journal.
avatar
Apeleutheros: Sorry, the NWN builder forum was down and I thought I'd ask this here just in case anyone here is familiar with the toolset.

I've been working on a module off and on for awhile now. In my module there is a journal in the starter chest that you can pick up and read that acts as part of the introduction to the story. I want to add the Player Character's <firstname> as a token into the book so that it ties the player into the events taking place in the journal. I can't get it to work, and the book just says <FirstName> or <PlayerName> or whatever token I attempt to insert.

Is there a way to add the PC's name into the book, or do I have to figure out how to make it work without tying the player's name into the narrative?

Just to be clear, this is a book I created in the Item Wizard and not part of the player's actual journal.
Tokens don't work in descriptions. You can use them in the character's journal, but not an item which is a journal.

However, starting with v.1.69, the devs introduced SetDescription and GetDescription.

So (this is off the top of my head and has not been tested):

// get all of your relevant variables. (you could avoid using a lot of these variables with some careful programming.
object oPC = <use a function to get your PC -- this could be when the chest is opened
string sName = GetName(oPC);
object oBook = <use a function or set of functions to get your book>
string sDesc = GetDescription(oBook);

// Replace the characters <name> with the player's name.
sDesc = StringReplace(sDesc, "<name>", sName);
SetDescription(oBook, sDesc);


That should do it. There's probably some functions to get the player's first and last name, but I don't know it off hand. You can tear through www.nwnlexicon.com to see if you can find something. I didn't see it.

As mentioned above, you can avoid a lot variables to speed things up a tiny bit by doing something like:

SetDescription(oBook, StringReplace(GetDescription(oBook), "<name>", GetName(oPC)));
But that was harder to read. :)

I hope that helps.

Once you get a fair amount done, you should share it with us!
avatar
Apeleutheros: Sorry, the NWN builder forum was down and I thought I'd ask this here just in case anyone here is familiar with the toolset.

I've been working on a module off and on for awhile now. In my module there is a journal in the starter chest that you can pick up and read that acts as part of the introduction to the story. I want to add the Player Character's <firstname> as a token into the book so that it ties the player into the events taking place in the journal. I can't get it to work, and the book just says <FirstName> or <PlayerName> or whatever token I attempt to insert.

Is there a way to add the PC's name into the book, or do I have to figure out how to make it work without tying the player's name into the narrative?

Just to be clear, this is a book I created in the Item Wizard and not part of the player's actual journal.
avatar
Tallima: Tokens don't work in descriptions. You can use them in the character's journal, but not an item which is a journal.

However, starting with v.1.69, the devs introduced SetDescription and GetDescription.

So (this is off the top of my head and has not been tested):

// get all of your relevant variables. (you could avoid using a lot of these variables with some careful programming.
object oPC = <use a function to get your PC -- this could be when the chest is opened
string sName = GetName(oPC);
object oBook = <use a function or set of functions to get your book>
string sDesc = GetDescription(oBook);

// Replace the characters <name> with the player's name.
sDesc = StringReplace(sDesc, "<name>", sName);
SetDescription(oBook, sDesc);

That should do it. There's probably some functions to get the player's first and last name, but I don't know it off hand. You can tear through www.nwnlexicon.com to see if you can find something. I didn't see it.

As mentioned above, you can avoid a lot variables to speed things up a tiny bit by doing something like:

SetDescription(oBook, StringReplace(GetDescription(oBook), "<name>", GetName(oPC)));
But that was harder to read. :)

I hope that helps.

Once you get a fair amount done, you should share it with us!
Thank you for the reply. Someone over at the new Vault mentioned GetDescription to me as well. When I feel up to it I might give it a try.

When I get something substantial done I will definitely share, though it might take awhile with wife my four kids lol. Right now it's still pretty skeletal. I get side tracked and get too far ahead of myself. Lately I've sat down and am taking a more methodical approach focusing on the hub area first so my plans for the module feel more coherent and concrete in my head.