Lua functions

SetPlayerProximityFunction

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

Historical signature: SetPlayerProximityFunction(spawn, distance, in_range_function, leaving_range_function)

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

Function: SetPlayerProximityFunction(spawn, distance, in_range_function, leaving_range_function)

Description: Registers callbacks on a non-Player spawn for Players entering and leaving its range. Callbacks receive (spawn, player). leaving_range_function may be omitted or empty.

Parameters:

  • spawn (Spawn) - The non-Player spawn whose script contains the callbacks.
  • distance (number) - Positive range in world units. Enter requires distance strictly less than this value; an active episode leaves only when distance is greater.
  • in_range_function (string) - Required nonempty enter callback name.
  • leaving_range_function (string, optional) - Leave callback name; empty means no leave callback.

Returns: None.

Behavior: Each continuous visit triggers one enter and one applicable leave callback. Registration is valid during the spawn's spawn callback, before pending world admission completes. Registering again replaces that spawn's previous configuration and starts a fresh episode. State belongs to the original spawn allocation and Client/Player session; a respawn, reconnect or replacement Player does not inherit the old episode. Removing or replacing a registration prevents later callbacks from being accepted; a callback already accepted finishes with its original actors and callback name. A leave callback may re-enter without the outer call erasing the new episode.

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.

SetPlayerProximityFunction(NPC, 15, "InRange", Spawn)

Evidence: server/SpawnScripts/antonica/BlartonBlumble.lua:20; binding EQ2Emu_lua_SetPlayerProximityFunction.

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