API Client - bellaouzo/PlayerState GitHub Wiki

Client API

Client-side PlayerState API for data access and change listeners.

Data Access Functions

Get()

Get(key) → any

Gets a top-level data value. Automatically waits for data to load with built-in caching for performance.

Parameters: key: string
Returns: any - The value, or nil if not found


GetPath()

GetPath(path) → any

Gets a nested data value using dot notation. Automatically waits for data to load with optimized nested value caching.

Parameters: path: ValuePath
Returns: any - The value, or nil if not found


GetAll()

GetAll() → PlayerData?

Gets all player data. Automatically waits for data to load.

Parameters: None
Returns: PlayerData? - Complete data table, or nil if not loaded


GetFromDict()

GetFromDict(dictPath, key) → any

Gets a value from a dictionary using a key with automatic type conversion and caching.

Parameters: dictPath: ValuePath, key: string | number
Returns: any - The value, or nil if not found


Status Functions

IsReady()

IsReady() → boolean

Checks if player data is ready and replica is active.

Parameters: None
Returns: boolean - True if data is ready, false otherwise


Cache Management Functions

ClearCache()

ClearCache() → void

Manually clears all internal caches. Useful for memory management or debugging.

Parameters: None
Returns: Nothing


Change Listener Functions

OnChanged()

OnChanged(pathOrKey, callback) → ReplicaClient.Connection?

Listens for changes to a specific data path or key with enhanced change information.

Parameters: pathOrKey: string, callback: (newValue: any, oldValue: any, changeInfo: ChangeInfo | {string}?) -> ()
Returns: ReplicaClient.Connection? - Connection to disconnect the listener


Advanced Functions

GetReplica()

GetReplica() → ReplicaInstance?

Gets the raw Replica instance for advanced operations.

Parameters: None
Returns: ReplicaInstance? - Replica instance, or nil if not loaded