A friend of mine is beginning to take an interest in building with NWN (EE), but he doesn’t have an account here yet, and since I have forgotten almost everything I ever knew about building - which wasn’t much to begin with - and I couldn’t help him, he asked me to post his question here in his stead:
"Suppose you wanted to make two modules where the second adventure continues story lines that were established in the first.
An NPC could have given the player a particular item as a reward for a quest in the first module. In the second module, a check could be made to see whether the player held this item. This would verify whether the quest had been completed.
But what if you wanted to check whether the player had completed the quest to help the NPC in the previous module without having to use an item? Is there a way this could be done?"
Shut down the currently loaded module and start a new one (moving all currently-connected players to the starting point.
Remarks
The StartNewModule command requires the filename of the module to start, not the internal name. There is a handy way to restart modules, used in testing, ie creating a unique power item that restarts the module this way:
StartNewModule(GetName(GetModule()));
GetName(GetModule()) returns the internal name, not the filename, so for that approach to work, the filename and the internal name of the module need to exactly the same.
Also note that if this is used with tag-based scripting, and is called within a On Item Aquired or On Item Activate event, then it might load, load up the reactivate module script via. the On Item Aquired firing (a recent change to the event for HotU), and do the same over and over. Be careful when using it - use it rarely for debugging and starting modules at the end of the current one.
Known Bugs
The bug / issue that caused StartNewModule to crash if called with an invalid filename has been fixed with patch 1.61. If the filename doesn’t exist, the function simply fails.
Version
1.64
Example
void main()
{
StartNewModule("module001");
}
// Restart the currently running module - IF the name of the
// module is the same as the filename of the module (see above).
void main()
{
StartNewModule(GetName(GetModule()));
}
Oh, so it’s as easy as that? You can just set variables on the PC directly and they will be stored on the character permanently, so they can be checked in other modules, too?
I could be wrong there but I figured if they have all their gear after moving to the next module, there shouldn’t be any reason why variables shouldn’t transfer. Get them to try it. If it doesn’t work, come back here and we’ll figure something out.
How does gear enter the equation? Did you mean the values would be stored on the PC’s gear (also items)?
I think the old Bioware tutorial about the Fern mines, probably halfway through by now. I also sent him links to the Guide to Building and the thread where you listed all kinds of useful material.
No. Just that if they arrive in the new module with all their gear from when they left the old module then it is reasonable to expect that the PC is saved in the background with all their variables and loaded into the new module. Might be that the PC is kept in memory but either way the variables on the PC should be intact.
In that case, they might be interested in the companion series I did to that tutorial. It’s on my blog in the wiki here -
Oh, I see. So this method would only work when the PC is still in the memory then? You couldn’t start the second module with the saved character, independently of the first module? Because that’s what my friend would prefer to do. I guess he will have to do it with items then after all?
What I mean is, would it also work if the character is exported, the game closed, the PC shut down, and then some other day the player would start the second module from the main menu and choose the exported character for it, without having to load module 1 again? If not, it’s good to know that this possibility exists, but my friend would not want to do it this way, as he’s not planning a saga with chapters but was more thinking about independent adventures that could nevertheless recognize if a PC had played any of the others before and reward the player in some way or other if they did.
The best solution I could come up with, with my limited knowledge, was to store values on an item that the PC would want to keep on them at all times, like some family heirloom that could not be given away. You can do that, store multiple values on the same item, right? He feared having to use a different item for each quest, that’s why he was looking for a solution without items, but one item wouldn’t be so bad.