Tool Meta
The ToolGun interacts with the world through specialized meta functions. This guide lists utilities for object manipulation and ghost entity management.
Overview
Tool meta functions track hovered entities, create ghost previews, and wrap common building operations. They ensure consistent behavior across custom tools in Lilia.
Create()
Description:
Creates a new tool object with default values.
Parameters:
- None
Realm:
- Shared
Returns:
- table – The newly created tool object.
Example Usage:
-- Create a table for a custom door tool mode
local tool = ToolGunMeta:Create()
tool.Mode = "lia_dooredit"
CreateConVars()
Description:
Creates client and server ConVars for this tool.
Parameters:
- None
Realm:
- Shared
Returns:
- None – This function does not return a value.
Example Usage:
GetServerInfo(property)
Description:
Returns the server ConVar for the given property.
Parameters:
- property (string) – Property name.
Realm:
- Shared
Returns:
- ConVar – The server ConVar object.
Example Usage:
-- Check if the server allows using this tool
local allow = tool:GetServerInfo("allow_use"):GetBool()
BuildConVarList()
Description:
Returns a table of client ConVars prefixed by the tool mode.
Parameters:
- None
Realm:
- Shared
Returns:
- table – Table of convars.
Example Usage:
GetClientInfo(property)
Description:
Retrieves a client ConVar value as a string.
Parameters:
- property (string) – ConVar name without mode prefix.
Realm:
- Shared
Returns:
- string – The value stored in the ConVar.
Example Usage:
GetClientNumber(property, default)
Description:
Retrieves a numeric client ConVar value.
Parameters:
-
property (string) – ConVar name without mode prefix.
-
default (number) – Value returned if the ConVar doesn't exist.
Realm:
- Shared
Returns:
- number – The numeric value of the ConVar.
Example Usage:
Allowed()
Description:
Determines whether this tool is allowed to be used.
Parameters:
- None
Realm:
- Shared
Returns:
- boolean – True if the tool is allowed.
Example Usage:
-- Check if the player can use the current tool
if tool:Allowed() then
tool:GetOwner():ChatPrint("Tool is permitted!")
hook.Run("PlayerToolPermitted", tool:GetOwner(), tool:GetMode())
else
tool:GetOwner():ChatPrint("Tool usage blocked.")
end
Init()
Description:
Placeholder for tool initialization.
Parameters:
- None
Realm:
- Shared
Returns:
- None – This function does not return a value.
Example Usage:
GetMode()
Description:
Gets the current tool mode string.
Parameters:
- None
Realm:
- Shared
Returns:
- string – Tool mode name.
Example Usage:
GetSWEP()
Description:
Returns the SWEP associated with this tool.
Parameters:
- None
Realm:
- Shared
Returns:
- SWEP – The tool's weapon entity.
Example Usage:
GetOwner()
Description:
Retrieves the tool owner's player object.
Parameters:
- None
Realm:
- Shared
Returns:
- Player – Owner of the tool.
Example Usage:
GetWeapon()
Description:
Retrieves the weapon entity this tool is attached to.
Parameters:
- None
Realm:
- Shared
Returns:
- Weapon – The weapon object.
Example Usage:
LeftClick()
Description:
Handles the left-click action. Override for custom behavior.
Parameters:
- None
Realm:
- Shared
Returns:
- boolean – False by default.
Example Usage:
RightClick()
Description:
Handles the right-click action. Override for custom behavior.
Parameters:
- None
Realm:
- Shared
Returns:
- boolean – False by default.
Example Usage:
Reload()
Description:
Clears stored objects when the tool reloads.
Parameters:
- None
Realm:
- Shared
Returns:
- None – This function does not return a value.
Example Usage:
Deploy()
Description:
Called when the tool is equipped. Releases ghost entity.
Parameters:
- None
Realm:
- Shared
Returns:
- None – This function does not return a value.
Example Usage:
Holster()
Description:
Called when the tool is holstered. Releases ghost entity.
Parameters:
- None
Realm:
- Shared
Returns:
- None – This function does not return a value.
Example Usage:
Think()
Description:
Called every tick; releases ghost entities by default.
Parameters:
- None
Realm:
- Shared
Returns:
- None – This function does not return a value.
Example Usage:
CheckObjects()
Description:
Validates stored objects and clears them if invalid.
Parameters:
- None
Realm:
- Shared
Returns:
- None – This function does not return a value.
Example Usage:
ClearObjects()
Description:
Removes all stored objects from the tool.
Parameters:
- None
Realm:
- Shared
Returns:
- None – This function does not return a value.
Example Usage:
ReleaseGhostEntity()
Description:
Removes the ghost entity used for previewing placements.
Parameters:
- None
Realm:
- Shared
Returns:
- None – This function does not return a value.
Example Usage: