Camera¶
Camera helpers for Lilia third-person view, realistic first-person view, freelook input, and local-player visibility handling.
Overview
lia.camera.isUsingThirdPersonCamera(client)View Source
Purpose
Checks whether the player is currently using the Lilia third-person camera override.
Realm
Client
Parameters
Player client The player whose view entity and camera eligibility should be checked.
Returns
boolean True when the player's view entity is themselves and third-person override is available.
Example Usage
local allowed = lia.camera.isUsingThirdPersonCamera()
if allowed then
print("lia.camera.isUsingThirdPersonCamera returned true for the current context.")
end
lia.camera.shouldSuppressRealisticView(client)View Source
Purpose
Determines whether realistic first-person view should be temporarily suppressed.
Realm
Client
Parameters
Player client The player whose input state should be checked.
Returns
boolean True when realistic view should be blocked for the current frame.
Example Usage
local allowed = lia.camera.shouldSuppressRealisticView()
if allowed then
print("lia.camera.shouldSuppressRealisticView returned true for the current context.")
end
lia.camera.canOverrideView(client)View Source
Purpose
Determines whether the client may currently use the Lilia third-person camera override.
Realm
Client
Parameters
Player client The player whose camera state should be checked.
Returns
boolean True when third-person view is enabled, configured, and not blocked by menus, vehicles, ragdolls, or hooks.
Example Usage
local allowed = lia.camera.canOverrideView()
if allowed then
print("lia.camera.canOverrideView returned true for the current context.")
end
lia.camera.canUseRealisticView(client)View Source
Purpose
Determines whether realistic first-person body view may be used for the local player.
Realm
Client
Parameters
Player client The local player being checked.
Returns
boolean True when realistic view is enabled and no state blocks it.
Example Usage
local allowed = lia.camera.canUseRealisticView()
if allowed then
print("lia.camera.canUseRealisticView returned true for the current context.")
end
lia.camera.canUseFreelook(client)View Source
Purpose
Determines whether freelook can be applied to the local player's current view.
Realm
Client
Parameters
Player client The local player being checked.
Returns
boolean True when freelook is enabled and available.
Example Usage
local allowed = lia.camera.canUseFreelook()
if allowed then
print("lia.camera.canUseFreelook returned true for the current context.")
end
lia.camera.isInSights(client)View Source
Purpose
Checks whether the player is aiming down sights with the active weapon.
Realm
Client
Parameters
Player client The player whose weapon and input state should be checked.
Returns
boolean True when ADS blocking is enabled and the player is considered in sights.
Example Usage
local allowed = lia.camera.isInSights()
if allowed then
print("lia.camera.isInSights returned true for the current context.")
end
lia.camera.isHoldingFreelookBind(client)View Source
Purpose
Checks whether the player is holding the freelook bind or the fallback walk key.
Realm
Client
Parameters
Player client The local player whose input state should be checked.
Returns
boolean True when freelook input is currently being held.
Example Usage
local allowed = lia.camera.isHoldingFreelookBind()
if allowed then
print("lia.camera.isHoldingFreelookBind returned true for the current context.")
end
lia.camera.resetFreelookState()View Source
lia.camera.beginFreelook(client)View Source
Purpose
Captures the player's current eye angles and marks freelook as actively held.
Realm
Client
Parameters
Player client The local player beginning freelook.
Example Usage
lia.camera.beginFreelook()
lia.camera.endFreelook()View Source
lia.camera.shouldDrawBodyForFreelook(client)View Source
Purpose
Determines whether the local player's body should be drawn for freelook.
Realm
Client
Parameters
Player client The local player being checked.
Returns
boolean True when freelook is active or still easing back toward center.
Example Usage
local allowed = lia.camera.shouldDrawBodyForFreelook()
if allowed then
print("lia.camera.shouldDrawBodyForFreelook returned true for the current context.")
end
lia.camera.getFirstPersonHeadBones(client)View Source
Purpose
Finds and caches head, neck, collar, clavicle, and upper chest bones for first-person hiding.
Realm
Client
Parameters
Player client The player model whose bones should be inspected.
Returns
table A cached list of bone indexes that should be hidden in first-person body view.
Example Usage
local result = lia.camera.getFirstPersonHeadBones()
if istable(result) then
PrintTable(result)
end
lia.camera.getFirstPersonHeadBoneChildren(client, rootBone)View Source
Purpose
Collects child bones parented under a first-person head-related root bone.
Realm
Client
Parameters
Player client The player model whose skeleton should be inspected.
number rootBone The root bone index used to find descendants.
Returns
table A list of child bone indexes under the given root bone.
Example Usage
local result = lia.camera.getFirstPersonHeadBoneChildren()
if istable(result) then
PrintTable(result)
end
lia.camera.getParentAttachmentNames(client)View Source
Purpose
Builds and caches a lookup of parent attachment names for the player model.
Realm
Client
Parameters
Player client The player model whose attachment names should be cached.
Returns
table A table keyed by attachment ID with lowercased attachment names.
Example Usage
local result = lia.camera.getParentAttachmentNames()
if istable(result) then
PrintTable(result)
end
lia.camera.isHeadAttachmentName(name)View Source
Purpose
Checks whether an attachment name appears to belong to head or face geometry.
Realm
Client
Parameters
string name The lowercased attachment name to inspect.
Returns
boolean True when the name matches a head, face, eye, mouth, or neck attachment.
Example Usage
local allowed = lia.camera.isHeadAttachmentName()
if allowed then
print("lia.camera.isHeadAttachmentName returned true for the current context.")
end
lia.camera.isHeadwearModel(model)View Source
Purpose
Checks whether a model path appears to represent headwear or face-worn geometry.
Realm
Client
Parameters
string model The model path to inspect.
Returns
boolean True when the model path matches known headwear terms.
Example Usage
local allowed = lia.camera.isHeadwearModel()
if allowed then
print("lia.camera.isHeadwearModel returned true for the current context.")
end
lia.camera.isHeadBodygroupName(name)View Source
Purpose
Checks whether a bodygroup name appears to control headwear or face geometry.
Realm
Client
Parameters
string name The bodygroup name to inspect.
Returns
boolean True when the bodygroup should be hidden for first-person body view.
Example Usage
local allowed = lia.camera.isHeadBodygroupName()
if allowed then
print("lia.camera.isHeadBodygroupName returned true for the current context.")
end
lia.camera.shouldHideFirstPersonChildEntity(client, entity)View Source
Purpose
Determines whether a child entity attached to the player should be hidden in first-person body view.
Realm
Client
Parameters
Player client The player whose attached entities are being inspected.
Entity entity The child entity being checked.
Returns
boolean True when the entity appears to be headwear, facewear, or nearby bonemerged head geometry.
Example Usage
local allowed = lia.camera.shouldHideFirstPersonChildEntity()
if allowed then
print("lia.camera.shouldHideFirstPersonChildEntity returned true for the current context.")
end
lia.camera.applyFreelookToAngles(client, angles)View Source
Purpose
Applies the current freelook offset to a camera angle when freelook is available.
Realm
Client
Parameters
Returns
Angle The adjusted camera angles.
Example Usage
local result = lia.camera.applyFreelookToAngles()
if result then
print(result)
end
lia.camera.buildRealisticView(client, origin, angles, fov)View Source
Purpose
Builds a realistic first-person view from the player's eye attachment or eye position.
Realm
Client
Parameters
Player client The local player.
Vector origin The original view origin.
Angle angles The original view angles.
number fov The current field of view.
Returns
table|nil A CalcView-compatible view table when realistic view can be built.
Example Usage
local result = lia.camera.buildRealisticView()
if istable(result) then
PrintTable(result)
end
lia.camera.buildFreelookBodyView(client, pos, ang, fov)View Source
Purpose
Builds a first-person body view while freelook is active or easing back to center.
Realm
Client
Parameters
Player client The local player.
Vector pos The original view position.
Angle ang The original view angles.
number fov The current field of view.
Returns
table|nil A CalcView-compatible view table when body rendering should be forced.
Example Usage
local result = lia.camera.buildFreelookBodyView()
if istable(result) then
PrintTable(result)
end
lia.camera.calcView(client, pos, ang, fov)View Source
Purpose
Builds the final Lilia camera view for third-person, realistic first-person, freelook body view, or the default first-person view.
Realm
Client
Parameters
Player client The player whose view is being calculated.
Vector pos The original view position.
Angle ang The original view angles.
number fov The current field of view.
Returns
table A CalcView-compatible table containing origin, angles, fov, and drawviewer when required.
Example Usage
hook.Add("CalcView", "liaCameraCalcView", lia.camera.calcView)
Hooks
Library-specific hooks documented for this library.
FreelookToggled(enabled)View Source
Purpose
Runs after the freelook console command changes freelook state.
Category
Camera
Realm
Client
Parameters
boolean enabled True when freelook was enabled, false when it was disabled.
Example Usage
hook.Add("FreelookToggled", "liaExampleFreelookToggled", function(enabled)
print("[MyModule] handled FreelookToggled")
end)
PreFreelookToggle(enabled)View Source
Purpose
Runs before the freelook console command changes freelook state.
Category
Camera
Realm
Client
Parameters
boolean enabled True when freelook is about to be enabled, false when it is about to be disabled.
Returns
boolean|nil Return false to block the freelook state change. Return nil or true to allow it.
Example Usage
hook.Add("PreFreelookToggle", "liaExamplePreFreelookToggle", function(enabled)
return true
end)
ShouldDisableThirdperson(client)View Source
Purpose
Allows plugins or modules to disable the Lilia third-person camera override for a client.
Category
Camera
Realm
Client
Parameters
Player client The player whose third-person camera availability is being checked.
Returns
boolean|nil Return true to block third-person view. Return nil or false to allow normal camera checks to continue.
Example Usage
hook.Add("ShouldDisableThirdperson", "liaExampleShouldDisableThirdperson", function(client)
return true
end)
ShouldUseFreelook(client)View Source
Purpose
Allows plugins or modules to prevent freelook input processing for the local player.
Category
Camera
Realm
Client
Parameters
Player client The local player whose freelook availability is being checked.
Returns
boolean|nil Return false to block freelook input. Return nil or true to allow normal freelook checks to continue.
Example Usage
hook.Add("ShouldUseFreelook", "liaExampleShouldUseFreelook", function(client)
return true
end)
ThirdPersonToggled(enabled)View Source
Purpose
Runs after the F4 third-person toggle changes the third-person option.
Category
Camera
Realm
Client
Parameters
boolean enabled True when third-person view was enabled, false when it was disabled.
Example Usage
hook.Add("ThirdPersonToggled", "liaExampleThirdPersonToggled", function(enabled)
print("[MyModule] handled ThirdPersonToggled")
end)