Lua functions

SetTempVariable

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

Historical signature: SetTempVariable(spawn, var, val)

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

Function: SetTempVariable(spawn, var, val)

Description: Sets a temporary named value on the receiver spawn. Passing nil removes the variable. Spawn, Zone, Item and Quest values remember their original allocation through weak observations; storing a value does not keep the referenced object alive or select a replacement under a reused ID/address.

Parameters:

  • spawn (Spawn): receiver actor.
  • var (string): nonempty variable name.
  • val: a string, supported Spawn/Zone/Item/Quest userdata, or nil. Numeric Lua values use the native string-conversion path. Other unsupported or expired userdata is rejected without changing the existing variable.

Returns: None. Invalid receivers, empty names, and invalid value types are logged without changing the variable.

Lifetime behavior: A Spawn value must resolve to a borrow owned by the current Lua invocation before its runtime identity is read. An actor already retained by the active invocation remains readable through that invocation even if it retires or its userdata is invalidated during a callback. A fresh invocation cannot revive an expired Spawn value. Zone values must acquire their original scene for assignment and remain weak in storage. Item and Quest values retain the original weak allocation behavior described below.

Checked example

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

SetTempVariable(NPC,"Reset",1)

Evidence: server/SpawnScripts/BrawlersDojo/afirstcircleadept.lua:62; binding EQ2Emu_lua_SetTempVariable.

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