SlashCo Wiki

EFFECT

EFFECT

Description

Table structure used for SlashCo.RegisterEffect.
An effect file (lua/slashco/effect/*.lua) builds a local EFFECT table, sets fields/callbacks on it, then calls SlashCo.RegisterEffect(EFFECT, "Name").
An effect is applied to a player via Player:AddEffect for a duration, and is much simpler than ITEM - most effect files only define Name plus a handful of the callbacks below.

Like ITEM, these fields/callbacks are looked up by name straight off the raw effect table (SlashCoEffects[effectName].CallbackName), so only the exact names listed here are ever read by the framework.
See ITEM for the equivalent item-slot fields (ITEM.Screenspace, ITEM.OnFootstep, ITEM.CanBeSeen, ITEM.CanSeeFlashlights, ITEM.OnDie, ITEM.OnOwnerTakeDamage, ITEM.PreDrawHalos, ITEM.Thirdperson, ITEM.PreDropSecondary, ITEM.PrePickUpPrimary, ITEM.PrePickUpSecondary) that these mirror - whichever of the two defines one of these names, the active effect always wins.

Parameters

string Name

The effect's display/registration name.
Used as the fallback identifier by SlashCo.RegisterEffect when its name argument is omitted (name = name or table.Name).

number FuelSpeed (Optional)

Multiplier for how fast a generator fuels while this effect is active on the player; divides the generator's DefaultTimeToFuel.
Checked through Player:ItemValue/Player:PerkValue, which look at active effects before either item slot - so this overrides any ITEM.FuelSpeed set by a held item while the effect is active. Used by the Buzzed, FuelSpeed, Balkan/BalkanTrip and BalkanTripWeak effects.

function OnApplied (Optional)

function(ply)
Called by Player:AddEffect right after the effect becomes active on the player (after any earlier expiry handling has already run).

function OnExpired (Optional)

function(ply)
Called when the effect naturally times out and no other stacked instance of it remains active, or as the fallback used in place of EFFECT.OnRemoved when that isn't defined (whether the effect is re-applied while active, or explicitly cleared).

function OnRemoved (Optional)

function(ply)
If defined, called instead of EFFECT.OnExpired whenever the effect is removed early - re-applied while already active (via Player:AddEffect), or explicitly cleared via Player:ClearEffect/Player:ClearEffects.

function Screenspace (Optional)

function()
Dispatched client-side via Player:ItemFunction every frame while the local survivor is alive, to draw custom post-processing/screen effects. Takes priority over the equivalent field on either of the player's items. Used by almost every shipped effect (e.g. Speed, Invisibility, Awareness, Dazed).

function OnFootstep (Optional)

function(ply) -> suppress
Dispatched via Player:ItemFunction, checked before the player's item. If it returns a truthy value, the player's footstep sound (and the "step notice" visual the Slasher would otherwise perceive) is suppressed. Used by Invisibility.

function CanBeSeen (Optional)

function(ply) -> visible
Dispatched via Player:ItemFunction, checked before the player's item, to override whether the player can currently be seen. Used by Invisibility to return false.

function OnOwnerTakeDamage (Optional)

function(ply, dmg) -> result
Dispatched via Player:ItemFunction, checked before the player's item, whenever the player 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. Used by Resistance to scale incoming damage down.

function CanSeeFlashlights (Optional)

function(ply) -> canSee
Same dispatch as EFFECT.CanBeSeen, overriding whether the player can see other players' flashlights. Not currently used by any shipped effect.

function OnDie (Optional)

function(ply) -> dontTickLife
Dispatched via Player:ItemFunction, checked before the player's item, when the player dies. Returning a truthy value skips the entire normal death sequence, the same as the identical field on ITEM. Not currently used by any shipped effect.

function PreDrawHalos (Optional)

function()
Dispatched client-side via Player:ItemFunction while halos are being drawn for the local survivor. Not currently used by any shipped effect.

function Thirdperson (Optional)

function() -> useThirdperson
Dispatched via Player:ItemFunction from CalcView, checked before the player's item, to decide whether to use a custom third-person camera. Not currently used by any shipped effect.

function PreDropSecondary (Optional)

function(ply, secondaryItem) -> dontDrop
Dispatched via Player:ItemFunction, checked before the player's primary item, right before the player's secondary item is dropped; returning a truthy value cancels the drop. Not currently used by any shipped effect.

function PrePickUpPrimary (Optional)

function(ply, item, itemindex) -> dontPickup
Dispatched via Player:SecondaryItemFunction, checked before the player's secondary item, right before a new primary item is picked up; returning a truthy value cancels the pickup. Not currently used by any shipped effect.

function PrePickUpSecondary (Optional)

function(ply, item, itemindex) -> dontPickup
Dispatched via Player:ItemFunction, checked before the player's primary item, right before a new secondary item is picked up; returning a truthy value cancels the pickup. Not currently used by any shipped effect.