ResManFindPrefix(string, int, int, int, string)

From NWN Lexicon
Jump to navigationJump to search
Nwnee logo.jpg Note: This article documents Neverwinter Nights: Enhanced Edition new content or changes/updates/fixes to 1.69 functions. These are all listed under the category and patches pages.

Finds the nNth available resref starting with sPrefix.

string ResManFindPrefix(
    string sPrefix,
    int nResType,
    int nNth = 1,
    int bSearchBaseData = FALSE,
    string sOnlyKeyTable = ""
);


Parameters

sPrefix
resref prefix to filter resref list with
nResType
blueprint RESTYPE constant for the blueprint
nNth
blueprint resource index
bSearchBaseData
optional parameter to specify searching base game resrefs
sOnlyKeyTable
optional parameter to specify keytable to search


Description

Finds the nNth available resref starting with sPrefix.


Remarks

  • The returned resref does not include the file suffix
  • Set bSearchBaseData to TRUE to also search base game content stored in your game installation directory.
   WARNING: This can be very slow.
   PW/Server Devs: bSearchBaseData, when used in a server-environment, only searches the server's files when producing results. You would need to extract the base game files and add them to the server's override folder for this function to pick up those files.
  • Set sOnlyKeyTable to a specific keytable to only search the given named keytable (e.g. "OVERRIDE:").

Returns "" if no such resref exists.

Does not seem to return the resrefs in any particular order.

Version

This function was added in 1.85.8193.31 of NWN:EE.


Example

// Execute all scripts that start with "load_"
void main()
{
    int i = 1;
    string sScript = ResManFindPrefix("load_", RESTYPE_NCS, i);
    while (sScript != "")
    {
        ExecuteScript(sScript, OBJECT_SELF);
        sScript = ResManFindPrefix("load_", RESTYPE_NCS, ++i);
    }
}

See Also

functions: ResManGetAliasFor() TemplateToJson()




author: Shadguy