Docs: Long Use Entity Base


Custom functions and network variables included in Long Use Entity Base

- - - - -

Functions


ENTITY.CancelUse - sv

void ENTITY:CancelUse( boolean callOnUseCancel = false )

Resets the entity to its initial state with no user or progress.

Supplying a true value to this function will call the entity's OnUseCancel hook.


ENTITY.GetDrawKeyPrompt - sv/cl

boolean ENTITY:GetDrawKeyPrompt()

Returns whether an image of the E key should show on-screen when this entity is usable by the player.

If unset, this defaults to true.


ENTITY.GetDrawProgress - sv/cl

boolean ENTITY:GetDrawProgress()

Returns whether a ring should show on-screen indicating the player's progress while using this entity.

If unset, this defaults to true.


ENTITY.GetEndTime - sv/cl

number ENTITY:GetEndTime()

Returns when the entity will be done being used.

This will return 0 if the entity is not currently being used.


ENTITY.GetUser - sv/cl

Entity ENTITY:GetUser()

Returns the entity (typically a player) that is currently using this entity.

This will return nil if the entity is not currently being used.


ENTITY.IsProgressUsable - sv/cl

boolean ENTITY:IsProgressUsable()

Returns true for the base and all derived entities.

WARNING: Do not override this function.


ENTITY.SetDrawKeyPrompt - sv/cl

void ENTITY:SetDrawKeyPrompt( boolean shouldDraw )

Sets whether an image of the E key should show on-screen when this entity is usable by the player.

If unset, this defaults to true.


ENTITY.SetDrawProgress - sv/cl

void ENTITY:SetDrawProgress( boolean shouldDraw )

Sets whether a ring should show on-screen indicating the player's progress while using this entity.

If unset, this defaults to true.


ENTITY.SetEndTime - sv/cl

void ENTITY:SetEndTime( number time )

Sets when the entity will be done being used.

WARNING: You probably shouldn't use this unless you know what you're doing.


ENTITY.SetUser - sv/cl

void ENTITY:SetUser( Entity user )

Sets the entity (typically a player) that is currently using this entity.

WARNING: You probably shouldn't use this unless you know what you're doing.


Hooks


ENTITY.OnUseCancel - sv

void ENTITY:OnUseCancel( Player user )

Called when the player lets go of their use key while they've been using the entity.

INFO: You should include this in your entity, even if it's empty.


ENTITY.OnUseFinish - sv

void ENTITY:OnUseFinish( Player user )

Called when this entity is finished being used, i.e. TimeToUse seconds after the user starts holding their use key.

INFO: You should include this in your entity, even if it's empty.


ENTITY.OnUseStart - sv

void ENTITY:OnUseStart( Player user )

Called when the player starts using this entity.

INFO: You should include this in your entity, even if it's empty.


Variables


ENT.PartialUse - number = 1

Which step of the PartialUses table the entity will execute next.

WARNING: You probably shouldn't use this unless you know what you're doing.


ENT.PartialUses - table = {}

A list of times and functions to be carried out while the entity is being used.

Each value in this table is a table with two values:

prog - a whole number corresponding to the percentage of progress func should be run

func - a function with one argument, ent (this entity), that is run at prog% of full use.

INFO: This table needs to be in chronological order to work properly.


ENT.ProgPerTick - number = 0

Deprecated. This needs to be removed.


ENT.TimeToUse - number = 1.5

The time in seconds it takes to use this entity.

This must be shared for the progress ring to draw properly.