Princess Artemis Posted January 20, 2006 Share Posted January 20, 2006 I've poked around and found there are ways to write conditional scripts that would look for a specific line in appearance.2da as a number...but I'm curious if there's a way to look for a script to look in the label column for the name of a character. For instance, I'm creating an NPC character for TSL, but I want him to have a conditional response that's specific for a custom PC character. Say the character's appearance is labeled P_FEM_LRG_99, but it would be impossible to know the row number because the PC character was added to the end of someone's appearances.2da using TSLPatcher. Is it possible to script a conditional so that the NPC would respond in a dialogue generically to other PCs but specifically to P_FEM_LRG_99? Link to comment Share on other sites More sharing options...
Det. Bart Lasiter Posted January 21, 2006 Share Posted January 21, 2006 There's no way to read from a *.2da file from a script. The only way to look up a row number would be to enter them into a struct, for instance: struct sExample { int nExample1 = 1; int nExample2 = 2; }; void main() { if(sExample.nExample == 1) { do_something(); } else { do_something_else(); } } Link to comment Share on other sites More sharing options...
stoffe Posted January 21, 2006 Share Posted January 21, 2006 For instance, I'm creating an NPC character for TSL, but I want him to have a conditional response that's specific for a custom PC character. Say the character's appearance is labeled P_FEM_LRG_99, but it would be impossible to know the row number because the PC character was added to the end of someone's appearances.2da using TSLPatcher. Is it possible to script a conditional so that the NPC would respond in a dialogue generically to other PCs but specifically to P_FEM_LRG_99? As far as I know GetAppearanceType() is the only way of checking in a script which appearance a character has (and, as you said, it only returns the line number in appearance.2da). Version 1.2 of TSLPatcher allows you to place tokens in a script make the patcher replace those tokens with the actual value before compiling that script. Thus, you should be able to store the line number (called RowIndex in the patcher config) in a 2DAMEMORY token, and then have the Patcher insert that number in the script. Like... if (GetAppearanceType(oNPC) == #2DAMEMORY1#) ... ...if you stored the line number in 2DAMEMORY1, and you add the script source to the Compile list. There's no way to read from a *.2da file from a script. The only way to look up a row number would be to enter them into a struct, for instance (snip) How would it help to use a struct for that? I don't see what that would accomplish? Link to comment Share on other sites More sharing options...
Princess Artemis Posted January 21, 2006 Author Share Posted January 21, 2006 Thanks for answering. I'll keep that trick in mind, but I won't be able to use it for what I'm doing now, since it was mainly something fun on the side with a friend's mod that I wanted to add to it. Link to comment Share on other sites More sharing options...
Det. Bart Lasiter Posted January 21, 2006 Share Posted January 21, 2006 How would it help to use a struct for that? I don't see what that would accomplish? To store the relevant data in it, then iterate through it to get the information copied from the *.2da instead of accessing the *.2da itself. Link to comment Share on other sites More sharing options...
stoffe Posted January 21, 2006 Share Posted January 21, 2006 To store the relevant data in it, then iterate through it to get the information copied from the *.2da instead of accessing the *.2da itself. Why would this be better than just using the integer constants directly in a conditional check? You can't loop through the member variables in a struct in NWScript anyway. Since the problem in this case is that you don't know what the new appearance IDs would be at design time, I don't think hardcoding the IDs in a script would help to solve the problem. Link to comment Share on other sites More sharing options...
Det. Bart Lasiter Posted January 21, 2006 Share Posted January 21, 2006 ^^^^ I managed to do this in C++; I forgot you can't assign variables to a value within structs with NWScript. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.