Item entity
Entity defined in core/entities/entities/cw_item
Shared definition of the cw_item entity: a non-spawnable anim entity named Item with a networked item Index
and an ENT:GetItemTable accessor.
Summary
Methods
ItemEntityDraw hook or the item's OnDrawModel returns false.cw.entity:FetchItemTable.OnEntityRemoved(entity) when the entity is removed and forgets the entity with item.RemoveItemEntity.Index integer holding the item's instance index.OnEntityThink.Methods
Draws the item model unless the ItemEntityDraw hook or the item's OnDrawModel returns false.
Plays a glass impact effect and a soft impact sound at the entity's position.
Returns the item instance fetched for this entity through cw.entity:FetchItemTable.
On the server this is overridden by the version in init.lua.
Returns
- Item The item instance, or
nilif it has not been fetched yet
Defined in
ENT:HUDPaintTargetID(x, y, alpha)
client gamemodes/catwork/gamemode/core/entities/entities/cw_item/cl_init.lua:13Draws the item name, weight and space when the item entity is looked at.
PaintItemTargetID must return true for anything to be drawn. The item's OnHUDPaintTargetID can draw
extra lines and returns the new y, or false to stop drawing.
Parameters
- x
- y
- alpha
Sets up physics, simple use and 25 health for the item entity.
Calls the item's OnEntityRemoved(entity) when the entity is removed and forgets the entity with
item.RemoveItemEntity.
ENT:OnTakeDamage(damageInfo)
server gamemodes/catwork/gamemode/core/entities/entities/cw_item/init.lua:90Applies damage above 5 to the entity's health and destroys it at zero health.
The item's OnEntityTakeDamage can return false to ignore the damage. Fires ItemEntityTakeDamage and,
when destroyed, the item's OnEntityDestroyed and the ItemEntityDestroyed hook.
Parameters
- damageInfo
ENT:SetItemTable(itemTable)
server gamemodes/catwork/gamemode/core/entities/entities/cw_item/init.lua:45Makes the entity represent an item instance.
Sets the item's model and skin, networks its index, calls the item's OnCreated(entity) and registers the
entity with item.AddItemEntity. Does nothing when itemTable is nil.
Parameters
- itemTable Item The item instance
ENT:SetupDataTables()
shared gamemodes/catwork/gamemode/core/entities/entities/cw_item/shared.lua:14Sets up the networked Index integer holding the item's instance index.
On the server
Removes entities stuck in the world or without an item, and runs the item's OnEntityThink.
OnEntityThink may return the number of seconds until the next think; the default is one second.
On the client
Requests the item data from the server until it arrives, then runs the item's OnEntityThink and the
ItemEntityThink hook.
Defined in
ENT:UpdateTransmitState()
server gamemodes/catwork/gamemode/core/entities/entities/cw_item/init.lua:30Always transmits the item entity to every client.