Skip to content
Toast edited this page Jan 4, 2024 · 11 revisions

The TARDIS features it's own hook system, separate from GMods one. It was created so that parts of the entity could easily communicate and ask questions to other parts of it. A good example of this is the ShouldDraw hook on the interior, which asks all the modules if it shouldn't be drawing for any reason. This type of system is extendible and allows multiple features to work together in harmony.

Most hooks in the TARDIS work in an "override principle", meaning you shouldn't return anything unless you want to "override" default behaviour. One example is EXTERIOR::CanTurnOnFlight. Returning false in this hook will prevent flight toggling, anything else (including nothing) will allow it. Obviously this only works with hooks that expect a return value. (Most hooks beggining with Can or Should expect at least one boolean)

For viewing convenience, the hooks list has been split between Client and Server in each case

Beware some hooks may not actually pass values listed here to functions when they're called. Always check for invalid values!

Direct entity hooks

Entity Hook Networking Description Returns Arguments
Common Use SERVER Direct hook into ENT:Use() - Entity/Player activator, Entity/Player caller
Common OnRemove SHARED Direct hook into ENT:OnRemove() - -
Common Think SHARED Direct hook into ENT:Think() - -
Common Initialize SHARED Direct hook into ENT:Initialize() - -
Exterior PhysicsUpdate SERVER Called on every physics update. - PhysObj physobj
Exterior PhysicsCollide SERVER Called when the TARDIS collides. - CollisionData colData, PhysObj collider
Exterior ShouldThinkFast SERVER Return true to think faster. Useful for accurate timesteps for e.g. animations. Bool -
Exterior BodygroupChanged SERVER Called when a bodygroup is changed. - bodygroup, value
Exterior SkinChanged SERVER Called when the exterior skin is changed. - Integer skinNumber
Common PlayerInitialize SERVER Used to initialize player data, net.Write* functions are available to send data to the client - Player ply
Common PlayerInitialize CLIENT Used to initialize client data, net.Read* functions are available to read server sent data - Player ply
Common PostPlayerInitialize SERVER Called after player data has been initialized - Player ply

Teleport

Entity Hook Networking Description Returns Arguments
Exterior StopDemat SHARED Called when the TARDIS has fully dematerialized. - -
Exterior CanDemat SERVER Called before dematerializing. Bool canDemat -
Exterior CanMat SERVER Return false to disallow materialisation. Bool canMat -
Exterior MatStart SERVER Called when materialization has started. - -
Exterior StopMat SERVER Called when the TARDIS has fully materialized. - -
Exterior VortexEnabled CLIENT Returns whether the vortex is enabled. Better to use Exterior:IsVortexEnabled(Player pilot)? - -
Exterior VortexEnabled SERVER Return false to hide the vortex, useful for e.g. Destination scanner camera. - -

Health and power

Entity Hook Networking Description Returns Arguments
Common PowerToggled SERVER Called when power has been toggled. Bool on is the new power state. - Bool on
Exterior CanTogglePower SERVER Called before power is toggled. Bool canToggle -
Common ShouldTakeDamage SERVER Called when damage is received. Return false to negate the damage. Bool takeDmg DamageInfo dmgInfo
Common OnHealthDepleted SERVER Called when health is zero. - -
Common OnHealthChange SERVER Triggered when health changes. - Number newhealth, Number oldhealth
Common OnTakeDamage SERVER Called whenever the TARDIS takes damage - DamageInfo damageinfo

Controls

Entity Hook Networking Description Returns Arguments
Interior PartUsed SERVER TardisPart part, Player activator - -
Interior CanUsePart SERVER Called before a part is used. Return false to refuse Bool TardisPart part, Player activator
Interior CanStartControlSequence SERVER Return false to prevent control sequence start Bool -
Exterior PilotChanged SHARED Called when the pilot changes. - Player oldPilot, Player newPilot
Exterior Destination CLIENT Called when Destination selection is entered (DeLorean teleporter) - Player ply, enabled
Exterior CanTurnOnFlight SERVER Called before flight is enabled. Bool canOn -
Exterior CanTurnOffFlight SERVER Called before flight is disabled. Bool canOff -
Exterior CanTurnOnFloat SERVER Called before float is enabled. Return false to refuse. Bool canOn -
Exterior CanTurnOffFloat SERVER Called before float is turned off. Return false to refuse. Bool canOff -
Exterior CanTriggerHads SERVER Called before HADS is triggered. Return false to prevent triggering. Bool canHads -

Door

Entity Hook Networking Description Returns Arguments
Common PlayerEnter SERVER Called when a player has entered the TARDIS. -
Common PlayerEnter CLIENT Called when the current player (LocalPlayer()) enters the TARDIS. - -
Exterior CanPlayerEnter SERVER Return false to disallow player entry. Bool canEnter ply
Exterior CanPlayerEnterDoor SERVER Return false to prevent anyone from entering via teleport (WALK+USE or when no interior) Bool canEnter -
Exterior PlayerExit SERVER Called when a player exits. - Player ply, Bool forced, Bool notp
Exterior PlayerExit CLIENT Called when the current player (LocalPlayer()) exits. - -
Exterior CanPlayerExit SERVER Called when a player tries to exit. Bool canExit Player ply
Exterior PostPlayerExit SERVER Called after a player has exited the interior. - Player ply, Bool forced, Bool notp
Exterior DoorCollisionOverride SERVER Return true to force doors to collide. Prevents player from walking through even if opened Bool shouldCollide -
Exterior ShouldExteriorDoorCollide SERVER Return false to stop exterior door from colliding Bool dontCollide -
Exterior CanToggleDoor SERVER Called when the door is going to be toggled. Bool canToggle Bool doorstate
Exterior CanLock SERVER Return true to allow locking Bool canLock -
Exterior LockedUse SERVER Called when the TARDIS is used while locked. Return true to suppress default locked message - Entity/Player activator, Entity/Player caller
Exterior ShouldEmitDoorSound CLIENT Return false to prevent door sounds Bool noSound -

Effects

Entity Hook Networking Description Returns Arguments
Exterior ShouldTurnOffFlightSound CLIENT Return true to force flight sound off. Bool shouldOff -
Exterior ShouldTurnOnLight CLIENT Queried to force the exterior lamp on. Bool forceOn -
Exterior ShouldTurnOffLight CLIENT Queried to force the exterior lamp off. Bool forceOff -
Exterior ShouldTurnOnRotorwash SERVER Return true to enable rotorwash, overridden by ShouldTurnOffRotorwash hook. - -
Exterior ShouldTurnOffRotorwash SERVER Return true to force rotorwash to turn off. Bool forceOff -
Exterior ShouldDrawProjectedLight CLIENT Queried before the exterior flashlight effect is drawn. Bool dontDraw -

Drawing

Entity Hook Networking Description Returns Arguments
Common Draw CLIENT Called when the TARDIS entity (interior / exterior) is drawn. - -
Common PreDraw CLIENT Called before the TARDIS entity (interior / exterior) is drawn. - -
Common DrawPart CLIENT Called when a part is drawn. - TardisPart part
Common PreDrawPart CLIENT Called before a part's own Draw() function. - TardisPart part
Interior ShouldDraw CLIENT Return false to hide the interior in the current drawing context Bool -
Interior ShouldDrawLight CLIENT Queried to know if the current light should be drawn Bool Int? lightID, DLight? light
Exterior PreDrawPortal CLIENT Called before any world portal is drawn. - -
Exterior PostDrawPortal CLIENT Called after any world portal is drawn. - -
Exterior ShouldNotRenderPortal CLIENT Queried if the world portal should be drawn. Bool dontRender, Bool drawBlack Entity portalParent, WorldPortal portal, WorldPortal exitPortal, Vector origin?
Interior PostDrawTranslucentRenderables CLIENT Called after translucent models are drawn - -