Lua functions

SetTarget

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

Historical signature: SetTarget(…) via current binding

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

Function: SetTarget(spawn, target)

Description: Sets the selected target of a Spawn. Pass nil or omit the target to clear the selection. Player sources follow the engine's visibility rules.

Parameters:

  • spawn (Spawn) - Actor whose selected target is changed.
  • target (Spawn or nil, optional) - Actor to select; nil or an omitted argument clears the selection.

Returns: None.

Selection identity and lifetime: The relationship stores a weak reference to the supplied actor allocation, rather than only its runtime ID. It does not keep the actor or zone alive. Later GetTarget calls cannot follow another allocation with a reused ID or address. Replacing or clearing the target publishes the normal Info update. Lua globals holding userdata also remain weak between protected callbacks. 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.

SetTarget(NPC,nil)

Evidence: server/SpawnScripts/BeggarsCourt/BarmaidMelia.lua:89; binding EQ2Emu_lua_SetTarget.

Current registration: WorldServer/Lua/LuaInterface.cpp.