From 2ae77b64410ffbc4cf46f951381406548ae7213c Mon Sep 17 00:00:00 2001 From: iThorgrim <125808072+iThorgrim@users.noreply.github.com> Date: Sun, 26 Jan 2025 15:17:59 +0100 Subject: [PATCH 1/2] feat(LuaEngine/GameObjectMethods): ddd SetRespawnDelay (#239) --- src/LuaEngine/LuaFunctions.cpp | 1 + src/LuaEngine/methods/GameObjectMethods.h | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/src/LuaEngine/LuaFunctions.cpp b/src/LuaEngine/LuaFunctions.cpp index 7aaded47b6..46aaf7255a 100644 --- a/src/LuaEngine/LuaFunctions.cpp +++ b/src/LuaEngine/LuaFunctions.cpp @@ -855,6 +855,7 @@ ElunaRegister GameObjectMethods[] = { "SetGoState", &LuaGameObject::SetGoState }, { "SetLootState", &LuaGameObject::SetLootState }, { "SetRespawnTime", &LuaGameObject::SetRespawnTime }, + { "SetRespawnDelay", &LuaGameObject::SetRespawnDelay }, // Boolean { "IsTransport", &LuaGameObject::IsTransport }, diff --git a/src/LuaEngine/methods/GameObjectMethods.h b/src/LuaEngine/methods/GameObjectMethods.h index 9a4ecafa3d..f55e1ae59f 100644 --- a/src/LuaEngine/methods/GameObjectMethods.h +++ b/src/LuaEngine/methods/GameObjectMethods.h @@ -353,5 +353,20 @@ namespace LuaGameObject go->SetRespawnTime(respawn); return 0; } + + /** + * Sets the respawn or despawn time for the gameobject. + * + * Respawn time is also used as despawn time depending on gameobject settings + * + * @param int32 delay = 0 : cooldown time in seconds to respawn or despawn the object. 0 means never + */ + int SetRespawnDelay(lua_State* L, GameObject* go) + { + int32 respawn = Eluna::CHECKVAL(L, 2); + + go->SetRespawnDelay(respawn); + return 0; + } }; #endif From 32d15a0003237ff4e0718af3ec2a38a2a68e7133 Mon Sep 17 00:00:00 2001 From: iThorgrim <125808072+iThorgrim@users.noreply.github.com> Date: Sun, 26 Jan 2025 15:21:18 +0100 Subject: [PATCH 2/2] feat(LuaEngine/ItemTemplateMethods): update GetName to support locale (#240) --- src/LuaEngine/methods/ItemTemplateMethods.h | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/LuaEngine/methods/ItemTemplateMethods.h b/src/LuaEngine/methods/ItemTemplateMethods.h index 401572cdd8..66980c9adf 100644 --- a/src/LuaEngine/methods/ItemTemplateMethods.h +++ b/src/LuaEngine/methods/ItemTemplateMethods.h @@ -45,13 +45,23 @@ namespace LuaItemTemplate } /** - * Returns the [ItemTemplate]'s name. + * Returns the [ItemTemplate]'s name in the [Player]'s locale. * + * @param [LocaleConstant] locale = DEFAULT_LOCALE : locale to return the [ItemTemplate] name in (it's optional default: LOCALE_enUS) + * * @return string name */ int GetName(lua_State* L, ItemTemplate* itemTemplate) { - Eluna::Push(L, itemTemplate->Name1); + uint32 loc_idx = Eluna::CHECKVAL(L, 2, LocaleConstant::LOCALE_enUS); + + const ItemLocale* itemLocale = eObjectMgr->GetItemLocale(itemTemplate->ItemId); + std::string name = itemTemplate->Name1; + + if (itemLocale && !itemLocale->Name[loc_idx].empty()) + name = itemLocale->Name[loc_idx]; + + Eluna::Push(L, name); return 1; }