Lua functions

SetSpellDataIndex

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

Historical signature: SetSpellDataIndex(spell, idx, value, value2)

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

Function: SetSpellDataIndex(spell, idx, value, value2)

Description: Prepares the values outside the spell mutex, then updates the selected Lua-data record as one operation and marks it for custom-spell persistence.

Parameters:

  • spell (Spell) - Lua spell object whose backing template owns the record.
  • idx (int32) - Zero-based index. Negative or out-of-range indexes are rejected; indexes above 255 are not truncated.
  • value (integer, number, boolean or string) - First value, using the record's existing type.
  • value2 (integer, number or string) - Second value for integer/float/string records; boolean records ignore it.

Returns: Boolean success for a valid record; false for an unsupported record type. Missing spell/data/index returns no values.

Record ownership: The backing template owns child values directly; readers receive copies and setters publish prepared edits. The instance must be admitted as described below; child-value ownership and VM execution are separate contracts. See Lua actor lifetime.

Checked example

Active call in a local runtime Lua script. The indexed value is read from the third argument. This is a contextual call pattern, not a tested standalone script.

SetSpellDataIndex(Spell, 1, MinDmg)

Evidence: server/Spells/Commoner/BlightoftheMorning.lua:24; binding EQ2Emu_lua_SetSpellDataIndex.

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