Lua functions

GetCharmedPet

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

Historical signature: GetCharmedPet(Spawn)

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

Function: GetCharmedPet(spawn)

Description: Return the entity's charmed pet from its original weak allocation reference. The native getter retains an operation loan and passes it into the current Lua invocation, so the returned actor remains readable through callbacks/retirement in that invocation. A different actor with the same runtime ID or address cannot inherit the relationship. Constructed and queued pets are available before active publication; stored userdata remains weak between calls.

Parameters:

  • spawn (Spawn) - Player or NPC entity that owns the pet.

Returns: The pet Spawn object, or nil if the owner is invalid, detached, has no pet in this category, or the pet has been retired or removed.

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.

pet = GetCharmedPet(Caster)

Evidence: server/Spells/Scout/Bard/Troubador/BriasEntrancingSonnet.lua:21; binding EQ2Emu_lua_GetCharmedPet.

Current registration: WorldServer/Lua/LuaInterface.cpp. Historical explanation: EQ2Emu Lua documentation.