diff --git a/CHANGELOG.md b/CHANGELOG.md index aaf9eb83ebd..e250b582335 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,7 @@ https://github.com/nwnxee/unified/compare/build8193.36.12...HEAD - Race: SuppressCreatureRaceEffects() - Race: ReactivateCreatureRaceEffects() - Creature: {Get|Set}MulticlassLimit() +- Util: UpdateResourceDirectory() ### Changed - Player: added bChatWindow parameter to FloatingTextStringOnCreature() diff --git a/Plugins/Util/NWScript/nwnx_util.nss b/Plugins/Util/NWScript/nwnx_util.nss index ef32e35515e..3ac3f14851d 100644 --- a/Plugins/Util/NWScript/nwnx_util.nss +++ b/Plugins/Util/NWScript/nwnx_util.nss @@ -263,6 +263,11 @@ int NWNX_Util_CleanResourceDirectory(string sAlias, int nResType = 0xFFFF); /// @return The name string NWNX_Util_GetModuleTlkFile(); +/// @brief Update a resource directory by having ResMan reindex it. +/// @param sAlias A resource directory alias, eg: TEMP +/// @return TRUE if successful, FALSE on error. +int NWNX_Util_UpdateResourceDirectory(string sAlias); + /// @} string NWNX_Util_GetCurrentScriptName(int depth = 0) @@ -657,3 +662,11 @@ string NWNX_Util_GetModuleTlkFile() NWNX_CallFunction(NWNX_Util, sFunc); return NWNX_GetReturnValueString(); } + +int NWNX_Util_UpdateResourceDirectory(string sAlias) +{ + string sFunc = "UpdateResourceDirectory"; + NWNX_PushArgumentString(sAlias); + NWNX_CallFunction(NWNX_Util, sFunc); + return NWNX_GetReturnValueInt(); +} diff --git a/Plugins/Util/Util.cpp b/Plugins/Util/Util.cpp index 12f377f8dbe..b52f5481754 100644 --- a/Plugins/Util/Util.cpp +++ b/Plugins/Util/Util.cpp @@ -798,3 +798,10 @@ NWNX_EXPORT ArgumentStack GetModuleTlkFile(ArgumentStack&& args) CNWSModule *pMod = Utils::GetModule(); return pMod->m_sModuleAltTLKFile; } + +NWNX_EXPORT ArgumentStack UpdateResourceDirectory(ArgumentStack&& args) +{ + const auto alias = args.extract(); + ASSERT_OR_THROW(!alias.empty()); + return Globals::ExoResMan()->UpdateResourceDirectory(alias + ":"); +}