ITEM
Description
Table structure used for SlashCo.RegisterItem.
An item file (lua/slashco/item/*.lua) builds a local ITEM table, sets fields/callbacks on it, then calls SlashCo.RegisterItem(ITEM, "Name").
Most callbacks below are looked up by name straight off the raw item table (SlashCoItems[item].CallbackName), not through a metatable, so only the exact names listed here are ever read by the framework.
ITEM.Screenspace, ITEM.PreDrawHalos, ITEM.Thirdperson, ITEM.OnFootstep, ITEM.CanBeSeen, ITEM.CanSeeFlashlights, ITEM.OnDie, ITEM.OnOwnerTakeDamage, ITEM.PreDropSecondary and ITEM.PrePickUpPrimary/ITEM.PrePickUpSecondary are all resolved through dispatch functions that check the player's active effects first - see EFFECT for the equivalent fields on an effect table, which take priority over an item's when both define the same one.
Parameters
Path to the item's world model.
Used as the default model for this item's own ViewModel/WorldModel/WorldModelHolstered tables, set on the physical pickup entity by sc_baseitem, shown in the item picker's preview panel, and readable off a secondary item via Player:ItemValue (e.g. by SlashCo.CreateItem calls made when a generator consumes a GasCan/Battery).
The item's display/registration name.
Used as the fallback identifier by SlashCo.RegisterItem when its name argument is omitted (name = name or table.Name).
Class name of the entity spawned when this item exists as a physical pickup in the world (via SlashCo.CreateItem).
Also used for the reverse lookup SlashCo.GetItemByEntity, and checked directly by some Slasher abilities via Player:ItemValue to detect a specific item (e.g. Princess/Sid checking for "sc_baby"/"sc_cookie").
How many Points the item costs in the lobby shop; deducted from the buyer's balance on purchase.
Items without this field are skipped entirely by the item picker's selection list (if not itemTbl.Price then continue end) - setting Price is what makes an item choosable at all, even a secondary item that is never actually bought (e.g. GasCan/Battery set Price = 0).
Camera offset used by the DModelPanel preview in the item picker UI (DModelPanel:SetCamPos).
If true, the item is added to SlashCo.SpawnableItems at load time, allowing it to spawn randomly in the world.
Default: false
If true, the item occupies the secondary ("item2") slot instead of the primary ("item") one.
Affects which slot Player:SetItem assigns it to, which slot is dropped/checked first by SlashCo.DropItem/SlashCo.ItemPickUp, and the color/styling of its box in the survivor HUD.
Default: false
If true, marks the item so it is skipped when SlashCo.DropItem is called with ignoreField = "Unbreakable".
"Unbreakable" isn't a hardcoded field name in SlashCo.DropItem itself, it's simply the string convention used by callers such as Slasher Tyler's ability (which drops/destroys whichever of a survivor's two items isn't marked this way) - only Battery currently sets it.
Render definition for the item as shown in the survivor's own hands (first person). If unset, nothing is rendered in the survivor's hands for this item.
Position offset from the view bone (ValveBiped.Bip01_Spine4, forced by the framework), relative to the bone's own angle.
If true, engine lighting is suppressed while this model is drawn (sic - matches the field name used in code).
Default: false
Render definition for the item as shown on the survivor's body (world/third person) while it is the currently equipped/active item. If unset, nothing is rendered in-hand in third person for this item.
Hold type passed to SWEP:SetHoldType while this item is equipped (e.g. "normal", "slam", "duel", "passive").
Name of the bone on the survivor model to attach to (looked up via Player:LookupBone).
If true, engine lighting is suppressed while this model is drawn.
Default: false
Render definition for the item as shown holstered on the survivor's body while the other slot is the one currently equipped/active. If unset, nothing is rendered holstered for this item.
Table of [bodygroupID] = value entries applied to the model.
If true, engine lighting is suppressed while this model is drawn.
Default: false
Language key shown as an extra tooltip line under the item's name box in the survivor HUD, in addition to the normal use/drop hints.
function()
Called by SlashCo.PrecacheItem, in addition to the automatic precaching of ITEM.Model. Use it to precache any extra models/sounds/materials this item needs.
function() -> number
If defined, caps how many survivors may hold this item at once. Enforced both server-side when buying it in the lobby shop, and client-side in the item picker (which greys out selection once the cap is reached).
function() -> string
If defined, called by SlashCo.ChangeSurvivorItem to get a sound path to play in place of the default random equip sound whenever this item is equipped.
function()
Called server-side right after a survivor purchases and equips this item through the lobby shop.
function(ply) -> r, g, b, a
Called by the survivor HUD to get the background color of the item's name box, called on the item itself (not affected by active effects). Falls back to a default color per slot if unset or if it returns nothing.
function(model, renderTable)
Called client-side every render frame, right before the equipped item's ViewModel/WorldModel/WorldModelHolstered table is applied to the clientside model panel, letting the item tweak renderTable (or model directly) beforehand. Not currently used by any shipped item.
function(model, renderTable)
Called client-side whenever the rendered clientside model panel's actual model changes to the one set by renderTable.model (e.g. to reset its sequence). Not currently used by any shipped item besides LabMeat.
function(ply, modelPanel)
Called client-side after this item's ViewModel has been rendered in the survivor's hands each frame. Not currently used by any shipped item.
function(ply, modelPanel)
Called client-side after this item's WorldModel has been rendered each frame while it is the active/equipped item. Not currently used by any shipped item.
function(ply, modelPanel)
Called client-side after this item's WorldModelHolstered has been rendered each frame while it is holstered. Not currently used by any shipped item.
Marks a secondary item as valid fuel for sc_generator; checked via Player:ItemValue("IsFuel", false, true).
Marks a secondary item as a valid battery for sc_generator; checked via Player:ItemValue("IsBattery", false, true).
Multiplier for how fast a generator fuels while this item is held; divides the generator's DefaultTimeToFuel (checked via Player:ItemValue/Player:PerkValue).
Default: 1
function(ply, generator)
Dispatched via Player:SecondaryItemFunction (so an active effect's OnFuel would take priority) when this ITEM.IsFuel secondary item is poured into a sc_generator. Not currently used by any shipped item.
function(ply, generator)
Dispatched the same way as ITEM.OnFuel, when this ITEM.IsBattery secondary item is installed into a sc_generator. Not currently used by any shipped item.
function(ply) -> doNotRemove
Called by SlashCo.UseItem when the survivor uses their held item (secondary slot takes priority). If it returns a truthy value the item stays equipped and an "item unusable" sound plays instead; otherwise the item is removed/consumed.
function(ply)
Called directly on the item (not through the effect-checked dispatch) right when it becomes newly equipped via SlashCo.ChangeSurvivorItem, whether from a world pickup or a lobby purchase.
function(ply)
Called on an item right before its slot's value changes away from it - when it's dropped, replaced by picking up another item, or removed via SlashCo.RemoveItem.
function(ply) -> dontDrop
Called on the item about to be dropped (secondary slot takes priority) at the very start of SlashCo.DropItem. Returning a truthy value cancels the drop entirely.
function(ply, secondaryItem) -> dontDrop
Declared on the primary item; dispatched via Player:ItemFunction (so an active EFFECT.PreDropSecondary takes priority) right before the secondary item is dropped, letting the primary item veto it. secondaryItem is the name of the item about to be dropped.
function(ply) -> height, dontDrop, dontPush
Called on the item after its slot has already been cleared, right before its dropped world entity is created.
height (number, optional, default 60): Z offset above the player to spawn the dropped entity at.
dontDrop (boolean, optional): if truthy, aborts creating the dropped entity (the slot has already been cleared by this point regardless).
dontPush (boolean, optional): if truthy, skips giving the dropped entity's physics object a push velocity/spin.
function(ply, droppedEntity, phys)
Called on the item right after its dropped world entity has been created (and, unless dontPush was set, launched).
function(ply, itemindex) -> dontPickup
Called on the item about to be picked up itself, via SlashCo.ItemPickUp. Returning a truthy value cancels the pickup.
function(ply, item, itemindex) -> dontPickup
Declared on a secondary item; dispatched via Player:SecondaryItemFunction right before a new primary item is picked up, letting the currently-held secondary item veto it. item is the name of the item about to be picked up.
function(ply, item, itemindex) -> dontPickup
Declared on a primary item; dispatched via Player:ItemFunction right before a new secondary item is picked up, letting the currently-held primary item veto it.
function(ply) -> visible
Dispatched via Player:ItemFunction (active effects take priority) to override whether the survivor holding this item can currently be seen. Return nil/nothing to not override.
function(ply) -> canSee
Same dispatch as ITEM.CanBeSeen, but overrides whether the survivor holding this item can see other players' flashlights.
function(ply) -> suppress
Dispatched via Player:ItemFunction. If it returns a truthy value, this survivor's footstep sound (and the "step notice" visual the Slasher would otherwise perceive) is suppressed.
function(ply) -> dontTickLife
Dispatched via Player:ItemFunction when the survivor dies. Returning a truthy value skips the entire normal death sequence (dropping all items, losing a life, spawning a ragdoll, moving to spectator) so the item can implement custom handling instead, e.g. DeathWard reviving the survivor.
function(ply, dmg) -> result
Dispatched via Player:ItemFunction whenever the survivor holding this item takes damage. Can mutate dmg in place (e.g. dmg:ScaleDamage(...)). If it returns a non-nil value, that value is returned from the gamemode's EntityTakeDamage hook (returning true blocks the damage entirely).
function()
Dispatched client-side via Player:ItemFunction every frame while the local survivor is alive, to draw custom post-processing/screen effects.
function()
Dispatched client-side via Player:ItemFunction while halos are being drawn for the local survivor. Not currently used by any shipped item.
function() -> useThirdperson
Dispatched via Player:ItemFunction from CalcView. If it returns a truthy value, the gamemode computes a custom third-person camera for the survivor; otherwise the default first-person view is used. Not currently used by any shipped item.