Lua functions

SetItemCount

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

Historical signature: SetItemCount(item, owner, new_count)

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

Function: SetItemCount(item, owner, new_count)

Description: Sets the count of the exact original item currently owned by the player. Zero removes that original; a bag removal includes its original contents only when every affected item can be admitted together. Values above the item's maximum stack count or the native count range are rejected without a change.

Parameters:

  • item (Item) - Userdata observing the original inventory or equipped item.
  • owner (Spawn) - The player who currently owns that exact item.
  • new_count (uint32) - New count; zero requests removal.

Returns: None. Rejected input or admission is reported to the script log.

Behavior: The binding retains the original item and player before native admission. It never selects a replacement by a reused ID. Count/removal commits together with an owned save handoff before packets or other callbacks. A changed player connection, spawn publication, source membership or reservation rejects the change. Packet rejection leaves the accepted change dirty for a later update.

A used script may lower its own reserved item's count. It retains the same reservation through the native change; only an accepted change satisfies that script's automatic charge. Other pending item uses, a busy child of a removed bag, or failed save admission leave the original unchanged. The function cannot adopt an observed item into another player's inventory.

Connection lifetime: The original player connection is retained through the native call. Reconnect or publication replacement cannot redirect the operation or later packets to a replacement session.

Checked example

No checked example is published for this function yet. No active script call with the current C++ argument count was found.

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