Vendor¶
Vendor helpers for shared preset registration, per-entity vendor property storage, synchronization, and vendor data snapshots.
Overview
lia.vendor.addPreset(name, items)View Source
Purpose
Registers or replaces a named vendor preset after filtering the supplied item table down to valid Lilia item IDs.
Realm
Shared
Parameters
string name The preset name to register. It is normalized to lowercase for storage.
table items A table keyed by item unique ID containing per-item vendor preset data.
Example Usage
lia.vendor.addPreset("medical", {
bandage = {mode = VENDOR_SELLANDBUY, price = 25}
})
lia.vendor.getPreset(name)View Source
Purpose
Returns a previously registered vendor preset by name.
Realm
Shared
Parameters
string name The preset name to look up. The lookup is normalized to lowercase.
Returns
table|nil The preset item definition table, or nil when the preset does not exist.
Example Usage
local preset = lia.vendor.getPreset("medical")
lia.vendor.getVendorProperty(entity, property)View Source
Purpose
Gets the current cached value for a vendor property, falling back to the library defaults when the entity is invalid or no override is stored.
Realm
Shared
Parameters
Entity entity optional The vendor entity whose property should be read.
string property The vendor property key to retrieve, such as `name`, `desc`, or `stockEnabled`.
Returns
any The stored property value when present, otherwise the property's default value.
Example Usage
local name = lia.vendor.getVendorProperty(vendor, "name")
lia.vendor.setVendorProperty(entity, property, value)View Source
Purpose
Sets or clears a cached vendor property override, removes values that match the library default, and synchronizes the change when running on the server.
Realm
Shared
Parameters
Entity entity The vendor entity whose cached data should change.
string property The vendor property key to update.
any value The new property value. Empty tables or default values are treated as clearing the override.
Example Usage
lia.vendor.setVendorProperty(vendor, "stockEnabled", true)
lia.vendor.syncVendorProperty(entity, property, value, isDefault)View Source
Purpose
Broadcasts a single vendor property update to clients so their cached vendor state matches the server.
Realm
Server
Parameters
Entity entity The vendor entity whose property changed.
string property The property key being synchronized.
any value The updated property value to send when the value is not defaulted.
boolean isDefault Whether the property has been reset to its default value and should be cleared clientside.
Example Usage
lia.vendor.syncVendorProperty(vendor, "name", "General Goods", false)
lia.vendor.getAllVendorData(entity)View Source
Purpose
Builds a table containing every tracked vendor property for an entity using current overrides and library defaults.
Realm
Shared
Parameters
Entity entity optional The vendor entity to inspect.
Returns
table A table of vendor property keys and their resolved values. Invalid entities return an empty table.
Example Usage
local snapshot = lia.vendor.getAllVendorData(vendor)