Doors
Door management system for the Lilia framework providing preset configuration,
Overview
The doors library provides comprehensive door management functionality including
preset configuration, database schema verification, and data cleanup operations.
It handles door data persistence, loading door configurations from presets,
and maintaining database integrity. The library manages door ownership, access
permissions, faction and class restrictions, and provides utilities for door
data validation and corruption cleanup. It operates primarily on the server side
and integrates with the database system to persist door configurations across
server restarts. The library also handles door locking/unlocking mechanics and
provides hooks for custom door behavior integration.
lia.doors.getDoorDefaultValues()
Purpose
Retrieve door default values merged with any extra fields provided by modules.
When Called
Anywhere door defaults are needed (initialization, schema checks, load/save).
Returns
table defaults Map of field -> default value including extra fields. table extras Map of extra field definitions collected via the CollectDoorDataFields hook.
lia.doors.getCachedData(door)
Purpose
Retrieve cached door data merged with defaults.
When Called
Before saving/loading or when building UI state for a door.
Parameters
Returns
table Complete door data with defaults filled.
Example Usage
local data = lia.doors.getCachedData(door)
print("Door price:", data.price)
lia.doors.addPreset(mapName, presetData)
Purpose
Register a preset of door data for a specific map.
When Called
During map setup to predefine door ownership/prices.
Parameters
Example Usage
lia.doors.addPreset("rp_downtown", {
[1234] = {name = "Bank", price = 0, factions = {FACTION_POLICE}},
[5678] = {locked = true, hidden = true}
})
lia.doors.getPreset(mapName)
Purpose
Retrieve a door preset table for a map.
When Called
During map load or admin inspection of presets.
Parameters
Returns
Example Usage
local preset = lia.doors.getPreset(game.GetMap())
if preset then PrintTable(preset) end
lia.doors.verifyDatabaseSchema()
Purpose
Validate the doors database schema against expected columns.
When Called
On startup or after migrations to detect missing/mismatched columns.
Example Usage
hook.Add("DatabaseConnected", "VerifyDoorSchema", lia.doors.verifyDatabaseSchema)
lia.doors.cleanupCorruptedData()
Purpose
Detect and repair corrupted faction/class door data in the database.
When Called
Maintenance task to clean malformed data entries.
Example Usage
concommand.Add("lia_fix_doors", function(admin)
if not IsValid(admin) or not admin:IsAdmin() then return end
lia.doors.cleanupCorruptedData()
end)
lia.doors.getData(door)
Purpose
Access cached door data (server/client wrapper).
When Called
Anywhere door data is needed without hitting DB.
Parameters
Returns
Example Usage
local data = lia.doors.getData(ent)
if data.locked then
-- show locked icon
end
lia.doors.getCachedData(door)
Purpose
Client helper to build full door data from cached entries.
When Called
For HUD/tooltips when interacting with doors.
Parameters
Returns
Example Usage
local info = lia.doors.getCachedData(door)
draw.SimpleText(info.name or "Door", "LiliaFont.18", x, y, color_white)
lia.doors.updateCachedData(doorID, data)
Purpose
Update the client-side cache for a door ID (or clear it).
When Called
After receiving sync updates from the server.
Parameters
number doorID
table data optional nil clears the cache entry.
Example Usage
lia.doors.updateCachedData(doorID, net.ReadTable())