Lua functions

GetEquippedItemBySlot

Registered in this checkout as EQ2Emu_lua_GetEquippedItemBySlot; implementation found at WorldServer/Lua/LuaFunctions.cpp:7575.

Historical signature: GetEquippedItemBySlot(…) via current binding

Parameter and behavior details in the historical explanation are under review against the current implementation.

Function: GetEquippedItemBySlot(spawn, slot)

Returns the original item currently equipped in a slot, as item userdata.

Parameters: spawn must be an entity (Player, NPC or Bot). slot is the equipment slot number, from 0 through 24.

Returns: One item userdata value when present. Invalid entities, slots or empty slots return no value (nil in a Lua expression), with an error log.

local item = GetEquippedItemBySlot(Player, 0)
if item ~= nil then print(GetItemID(item)) end

Original item lifetime: The collection selects and acquires the original item loan while holding its lock. Marshalling admits that loan into the protected Lua invocation. The userdata itself remembers a weak original allocation control; saved Lua values cannot extend publication or follow address reuse. An admitted invocation keeps its original item through retirement/expiration until the callback ends. Later invocations reject retired originals. See Lua actor lifetime.

Checked example

Active call in a local runtime Lua script. Argument count matches current fixed C++ readers. This is a contextual call pattern, not a tested standalone script.

local rangedItem = GetEquippedItemBySlot(Caster, 16)

Evidence: server/Spells/ClassicRefresh/Scout/Bard/Dirge/JaelsDreadfulDepletion-2552180.lua:18; binding EQ2Emu_lua_GetEquippedItemBySlot.

Current registration: WorldServer/Lua/LuaInterface.cpp.