Doors Library
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()
Retrieve door default values merged with any extra fields provided by modules.
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.setCachedData(door, data)
Store door data overrides in memory and sync to clients, omitting defaults.
After editing door settings (price, access, flags) server-side.
Parameters:
Entity door Door entity.table data Door data overrides.
Example Usage:
lia.doors.setCachedData(door, {
name = "Police HQ",
price = 0,
factions = {FACTION_POLICE}
})
lia.doors.getCachedData(door)
Retrieve cached door data merged with defaults.
Before saving/loading or when building UI state for a door.
Parameters:
Entity doorReturns:
table Complete door data with defaults filled.Example Usage:
local data = lia.doors.getCachedData(door)
print("Door price:", data.price)
lia.doors.syncDoorData(door)
Net-sync a single door's cached data to all clients.
After updating a door's data.
Parameters:
Entity doorExample Usage:
lia.doors.syncDoorData(door)
lia.doors.syncAllDoorsToClient(client)
Bulk-sync all cached doors to a single client.
On player spawn/join or after admin refresh.
Parameters:
Player clientExample Usage:
hook.Add("PlayerInitialSpawn", "SyncDoorsOnJoin", function(ply)
lia.doors.syncAllDoorsToClient(ply)
end)
lia.doors.setData(door, data)
Set data for a door (alias to setCachedData).
Convenience wrapper used by other systems.
Parameters:
Entity doortable data
Example Usage:
lia.doors.setData(door, {locked = true})
lia.doors.addPreset(mapName, presetData)
Register a preset of door data for a specific map.
During map setup to predefine door ownership/prices.
Parameters:
string mapNametable presetData
Example Usage:
lia.doors.addPreset("rp_downtown", {
[1234] = {name = "Bank", price = 0, factions = {FACTION_POLICE}},
[5678] = {locked = true, hidden = true}
})
lia.doors.getPreset(mapName)
Retrieve a door preset table for a map.
During map load or admin inspection of presets.
Parameters:
string mapNameReturns:
table|nilExample Usage:
local preset = lia.doors.getPreset(game.GetMap())
if preset then PrintTable(preset) end
lia.doors.verifyDatabaseSchema()
Validate the doors database schema against expected columns.
On startup or after migrations to detect missing/mismatched columns.
Example Usage:
hook.Add("DatabaseConnected", "VerifyDoorSchema", lia.doors.verifyDatabaseSchema)
lia.doors.cleanupCorruptedData()
Detect and repair corrupted faction/class door data in the database.
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)
Access cached door data (server/client wrapper).
Anywhere door data is needed without hitting DB.
Parameters:
Entity doorReturns:
tableExample Usage:
local data = lia.doors.getData(ent)
if data.locked then
-- show locked icon
end
lia.doors.getCachedData(door)
Client helper to build full door data from cached entries.
For HUD/tooltips when interacting with doors.
Parameters:
Entity doorReturns:
tableExample Usage:
local info = lia.doors.getCachedData(door)
draw.SimpleText(info.name or "Door", "LiliaFont.18", x, y, color_white)
lia.doors.updateCachedData(doorID, data)
Update the client-side cache for a door ID (or clear it).
After receiving sync updates from the server.
Parameters:
number doorIDtable data optional nil clears the cache entry.
Example Usage:
lia.doors.updateCachedData(doorID, net.ReadTable())