Skip to content

Doors

Door data helpers for storing, syncing, validating, and extending map door configuration.


Overview

The door library centralizes shared and networked door metadata under `lia.doors`. It stores only values that differ from defaults, merges custom door fields collected by hooks, synchronizes cached door data to clients, manages map presets, and verifies or repairs persisted door database data on the server.

lia.doors.getDoorDefaultValues()View Source

Purpose

Builds the complete default door data table, including custom fields collected from plugins or modules.

Realm

Shared

Returns

table A copy of the base door defaults with collected custom field defaults merged in. table The collected custom field definitions keyed by field name.

Example Usage

  local defaults, extras = lia.doors.getDoorDefaultValues()
  print(defaults.price, extras.customField)

lia.doors.setCachedData(door, data)View Source

Purpose

Stores filtered door data in the server cache and synchronizes the result to clients.

Realm

Server

Parameters

Entity door The door entity whose cached data should be updated.

table data optional Door data to cache. Values matching defaults are omitted, and empty table values are ignored.

Example Usage

  lia.doors.setCachedData(door, {
      name = "Apartment 1A",
      price = 250
  })

lia.doors.getCachedData(door)View Source

Purpose

Returns complete door data for a server-side door by merging cached values with defaults.

Realm

Server

Parameters

Entity door The door entity whose data should be retrieved.

Returns

table Complete door data for the entity. Returns an empty table when the entity has no valid map creation ID.

Example Usage

  local data = lia.doors.getCachedData(door)
  print(data.name, data.price)

lia.doors.syncDoorData(door)View Source

Purpose

Sends the current cached data for a single door to all connected clients.

Realm

Server

Parameters

Entity door The door entity whose cached data should be synchronized.

Example Usage

  lia.doors.syncDoorData(door)

lia.doors.syncAllDoorsToClient(client)View Source

Purpose

Sends the complete server-side door cache to a specific client.

Realm

Server

Parameters

Player client The player who should receive the full cached door data table.

Example Usage

  lia.doors.syncAllDoorsToClient(client)

lia.doors.setData(door, data)View Source

Purpose

Updates server-side door data through the cached data setter.

Realm

Server

Parameters

Entity door The door entity whose data should be updated.

table data optional Door data to apply to the entity.

Example Usage

  lia.doors.setData(door, {
      locked = true,
      hidden = false
  })

lia.doors.addPreset(mapName, presetData)View Source

Purpose

Registers a named door preset for a map.

Realm

Server

Parameters

string mapName The map name or map equivalency name used as the preset key.

table presetData The preset door data to associate with the map.

Example Usage

  lia.doors.addPreset("rp_city", presetData)

lia.doors.getPreset(mapName)View Source

Purpose

Retrieves the registered door preset for a map.

Realm

Server

Parameters

string mapName The map name or map equivalency name used as the preset key.

Returns

table|nil The preset data registered for the map, or nil when no preset exists.

Example Usage

  local preset = lia.doors.getPreset(game.GetMap())

lia.doors.verifyDatabaseSchema()View Source

Purpose

Verifies the persisted door database table against expected columns and adds missing custom field columns.

Realm

Server

Example Usage

  lia.doors.verifyDatabaseSchema()

lia.doors.cleanupCorruptedData()View Source

Purpose

Searches persisted door records for corrupted faction or class data and clears invalid values.

Realm

Server

Example Usage

  lia.doors.cleanupCorruptedData()

lia.doors.getData(door)View Source

Purpose

Retrieves complete door data for the current realm.

Realm

Shared

Parameters

Entity door The door entity whose merged data should be returned.

Returns

table Complete door data for the entity, with cached values merged over defaults.

Example Usage

  local data = lia.doors.getData(door)
  print(data.title)

lia.doors.getCachedData(door)View Source

Purpose

Returns complete door data for a client-side door by merging synced cached values with defaults.

Realm

Client

Parameters

Entity door The door entity whose synced data should be retrieved.

Returns

table Complete door data for the entity. Returns an empty table when the entity has no valid map creation ID.

Example Usage

  local data = lia.doors.getCachedData(door)
  print(data.hidden)

lia.doors.updateCachedData(doorID, data)View Source

Purpose

Updates or clears the client-side cached data for a door ID after receiving synchronized server data.

Realm

Client

Parameters

number doorID The map creation ID of the door whose cached data should be changed.

table data optional The synced cached data to store. Passing nil clears the stored data for the door ID.

Example Usage

  lia.doors.updateCachedData(doorID, data)