From 4bf88801ed3a44842224c9061630db9c9ae504e7 Mon Sep 17 00:00:00 2001 From: fallenoak Date: Fri, 6 Feb 2026 06:43:00 -0600 Subject: [PATCH] feat(ui): implement Script_GetInventorySlotInfo --- src/ui/game/CharacterInfoScript.cpp | 39 ++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/src/ui/game/CharacterInfoScript.cpp b/src/ui/game/CharacterInfoScript.cpp index 1b70462..295bbd7 100644 --- a/src/ui/game/CharacterInfoScript.cpp +++ b/src/ui/game/CharacterInfoScript.cpp @@ -1,11 +1,48 @@ #include "ui/game/CharacterInfoScript.hpp" +#include "db/Db.hpp" #include "ui/FrameScript.hpp" +#include "util/Lua.hpp" #include "util/Unimplemented.hpp" namespace { int32_t Script_GetInventorySlotInfo(lua_State* L) { - WHOA_UNIMPLEMENTED(0); + if (!lua_isstring(L, 1)) { + luaL_error(L, "Invalid inventory slot in GetInventorySlotInfo"); + return 0; + } + + auto slotName = lua_tostring(L, 1); + + PaperDollItemFrameRec* slotRec = nullptr; + for (int32_t i = 0; i < g_paperDollItemFrameDB.GetNumRecords(); i++) { + auto paperDollItemFrameRec = g_paperDollItemFrameDB.GetRecordByIndex(i); + + if (paperDollItemFrameRec && !SStrCmpI(slotName, paperDollItemFrameRec->m_itemButtonName)) { + slotRec = paperDollItemFrameRec; + break; + } + } + + if (!slotRec) { + luaL_error(L, "Invalid inventory slot in GetInventorySlotInfo"); + return 0; + } + + // id + lua_pushnumber(L, slotRec->m_slotNumber); + + // textureName + lua_pushstring(L, slotRec->m_slotIcon); + + // checkRelic + if (slotRec->m_slotNumber == EQUIPPED_LAST) { + lua_pushnumber(L, 1.0); + } else { + lua_pushnil(L); + } + + return 3; } int32_t Script_GetInventoryItemsForSlot(lua_State* L) {