From 9b27ad72f18d4924d0851a523b64fbff0c779620 Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Sun, 22 Aug 2021 19:03:03 +0200 Subject: [PATCH] Adds helper function to add definition to the script library. --- BuildLibrary.hpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/BuildLibrary.hpp b/BuildLibrary.hpp index 2272b68..661b8b5 100644 --- a/BuildLibrary.hpp +++ b/BuildLibrary.hpp @@ -14,7 +14,9 @@ class BuildLibrary { static PkmnLib::Library::TimeOfDay GetTime() { return PkmnLib::Library::TimeOfDay::Morning; } public: - static PkmnLib::Battling::BattleLibrary* Build(const std::string& pathString) { + static PkmnLib::Battling::BattleLibrary* + Build(const std::string& pathString, + std::function onScriptInitialize = {}) { auto path = std::filesystem::path(pathString); auto* typesLibrary = BuildTypes::Build(path / "Types.csv"); auto* natureLibrary = BuildNatures::Build(path / "Natures.csv"); @@ -41,6 +43,9 @@ public: scriptResolver->Initialize(battleLib); + if (onScriptInitialize) { + onScriptInitialize(scriptResolver); + } auto asScriptResolver = dynamic_cast(scriptResolver); for (const auto& dirEntry : std::filesystem::recursive_directory_iterator(scriptsPath)) {