FrameworkZ API Documentation - FrameworkZ.Foundation

FrameworkZ.Foundation

core

Foundational systems for FrameworkZ.

11
Functions
97
Methods
14
Fields

📋 On This Page

Fields

14
FrameworkZ.Foundation 📋 table
Foundational systems for FrameworkZ.
Initial value: {}
FrameworkZ.Foundation 📦 object
The foundational systems for FrameworkZ.
Initial value: FrameworkZ.Foundation.New()
FrameworkZ.Foundation.Events 📋 table
Contains all event handling functions for the Foundation system.
Initial value: {}
FrameworkZ.Foundation.HookHandlers 📋 table
Collection of hook handlers organized by category. Each category contains hooks that can be registered.
Initial value: { framework = {}, module = {}, gamemode = {}, plugin = {}, generic = {} }
FrameworkZ.Foundation.Modules ❓ unknown
Contains modules for FrameworkZ. Extends the framework with additional functionality.
Initial value: FrameworkZ.Foundation.Modules or {}
FrameworkZ.Foundation.Namespaces ❓ unknown
Collection of registered namespaces for data storage.
Initial value: FrameworkZ.Foundation.Namespaces or {}
FrameworkZ.Foundation.NetworksName 📝 string
The name of the networking module for commands in OnClientCommand and OnServerCommand. Not to be confused with a FrameworkZ module.
Initial value: "FZ_NETWORKS"
FrameworkZ.Foundation.PendingConfirmations 📋 table
Pending confirmations for network requests. This is used to track requests that are waiting for a response.
Initial value: {}
FrameworkZ.Foundation.RegisteredHooks 📋 table
Collection of registered hook functions organized by category and hook name.
Initial value: { framework = {}, module = {}, gamemode = {}, plugin = {}, generic = {} }
FrameworkZ.Foundation.StorageName 📝 string
STORAGE BACKEND - The base name used for storage operations.
Initial value: "FZ_STORAGE"
FrameworkZ.Foundation.Subscribers 📋 table
Subscribers for the network system. This is used to track subscribers for channels.
Initial value: {}
FrameworkZ.Foundation.SubscribersMeta 📋 table
Meta data for the subscribers. This is used to track when a channel was created and when it was last fired.
Initial value: {}
FrameworkZ.Foundation.SyncQueues ❓ unknown
Queues for batching synchronization operations.
Initial value: FrameworkZ.Foundation.SyncQueues or {}
FrameworkZ.Foundation.version 📝 string
Version information for the Foundation system.
Initial value: "1.0.0"

Methods

97

FrameworkZ.Foundation.Events:EveryDays()

method
Daily timer event that executes once per in-game day.

FrameworkZ.Foundation.Events:OnClientCommand(module, command, isoPlayer, arguments)

method
Handles client commands received on the server.

Parameters

module 📝 string
The module name that sent the command.
command 📝 string
The command that was sent.
isoPlayer 📦 object
The player object that sent the command.
arguments 📋 table
The arguments that were sent with the command.

FrameworkZ.Foundation.Events:OnConnected()

method
Called when a player connects to the server.

FrameworkZ.Foundation.Events:OnCreatePlayer()

method
Called when a new player character is created.

FrameworkZ.Foundation.Events:OnDisconnect()

method
Called when a player disconnects from the server.

FrameworkZ.Foundation.Events:OnFillInventoryObjectContextMenu(player, context, items)

method
Called when filling an inventory object's context menu.

Parameters

player 📦 object
The player object.
context 📦 object
The context menu object.
items 📋 table
The items being examined.

FrameworkZ.Foundation.Events:OnFillWorldObjectContextMenu(playerNumber, context, worldObjects, test)

method
Called when filling a world object's context menu.

Parameters

playerNumber 🔢 integer
The player number.
context 📦 object
The context menu object.
worldObjects 📋 table
The world objects being examined.
test ✅ boolean
Test parameter.

FrameworkZ.Foundation.Events:OnGameStart()

method
Called when the game starts.

FrameworkZ.Foundation.Events:OnInitGlobalModData(isNewGame)

method
Called when global mod data is initialized.

Parameters

isNewGame ✅ boolean
Whether this is a new game or loading an existing one.

FrameworkZ.Foundation.Events:OnKeyStartPressed(key)

method
Called when a key starts being pressed.

Parameters

key 🔢 integer
The key code that was pressed.

FrameworkZ.Foundation.Events:OnMainMenuEnter()

method
Called when entering the main menu.

FrameworkZ.Foundation.Events:OnObjectLeftMouseButtonDown(object, x, y)

method
Called when the left mouse button is pressed down on an object.

Parameters

object 📦 object
The object that was clicked.
x 🔢 integer
The X coordinate of the click.
y 🔢 integer
The Y coordinate of the click.

FrameworkZ.Foundation.Events:OnPlayerDeath(player)

method
Called when a player dies.

Parameters

player 📦 object
The player object that died.

FrameworkZ.Foundation.Events:OnPreFillInventoryObjectContextMenu(playerID, context, items)

method
Called before filling an inventory object's context menu.

Parameters

playerID 🔢 integer
The player ID.
context 📦 object
The context menu object.
items 📋 table
The items being examined.

FrameworkZ.Foundation.Events:OnReceiveGlobalModData(key, data)

method
Called when global mod data is received.

Parameters

key 📝 string
The key of the data received.
data 🏷️ mixed
The data that was received.

FrameworkZ.Foundation.Events:OnResetLua(reason)

method
Called when the Lua state is reset.

Parameters

reason 📝 string
The reason for the reset.

FrameworkZ.Foundation.Events:OnServerCommand(module, command, arguments)

method
Handles server commands received on the client.

Parameters

module 📝 string
The module name that sent the command.
command 📝 string
The command that was sent.
arguments 📋 table
The arguments that were sent with the command.

FrameworkZ.Foundation.Events:OnServerStarted()

method
Called when the server starts.

FrameworkZ.Foundation:AddAllHookHandlers(hookName)

method
Add a new hook handler to the list for all categories.

Parameters

hookName 📝 string
The name of the hook handler to add.

FrameworkZ.Foundation:AddChannel(key)

method
Add a new channel to the network system. Channels are used to subscribe to; changes in values, or fire events.

Parameters

key 📝 string
or \table The key to use for the channel. Use a table to create nested channels. \see FrameworkZ.Foundation::Subscribe for an example on how to supply a table as a key.

FrameworkZ.Foundation:AddHookHandler(hookName, category)

method
Add a new hook handler to the list.

Parameters

hookName 📝 string
The name of the hook handler to add.
category 📝 string
The category of the hook (framework, module, plugin, generic). Defaults to HOOK_CATEGORY_GENERIC if not specified.

FrameworkZ.Foundation:Broadcast(namespace, key, remove)

method
Broadcasts updated or removed data to all clients.

Parameters

namespace 📝 string
The namespace containing the data.
key 📝 string
The key being broadcast.
remove ✅ boolean
Whether this is a removal operation.

FrameworkZ.Foundation:CleanupConfirmations(timeout)

method
Cleans up pending confirmations that have not been confirmed within a timeout period.

Parameters

timeout 🔢 number
The timeout in seconds to clean up pending confirmations. Default: 300 seconds (5 minutes).

FrameworkZ.Foundation:ClearBatchSyncQueue(isoPlayer)

method
Clear the sync queue for a player.

Parameters

isoPlayer 📦 object
The player whose queue to clear.

FrameworkZ.Foundation:EveryDays()

method
TODO move to shared timer hook

FrameworkZ.Foundation:ExecuteAllHooks(hookName, ...)

method
Execute all of the hooks.

Parameters

hookName 📝 string
The name of the hook.

FrameworkZ.Foundation:ExecuteFrameworkHooks(hookName, ...)

method
Execute the framework hooks.

Parameters

hookName 📝 string
The name of the hook.

FrameworkZ.Foundation:ExecuteGamemodeHooks(hookName, ...)

method
Execute the gamemode hooks.

Parameters

hookName 📝 string
The name of the hook.

FrameworkZ.Foundation:ExecuteGenericHooks(hookName, ...)

method
Execute generic hooks.

Parameters

hookName 📝 string
The name of the hook.

FrameworkZ.Foundation:ExecuteHook(hookName, category, ...)

method
Execute a given hook by its hook name for its given category.

Parameters

hookName 📝 string
The name of the hook.
category 📝 string
The category of the hook (framework, module, plugin, generic). Defaults to HOOK_CATEGORY_GENERIC if not specified.

📝 Notes

When a function is defined and registered as a hook, sometimes it's as an object. However in the definition it could be as some.func() or some:func() (notice the period and colon between the examples). If the function is defined as some:func() then the object is passed as the first argument. If the function is defined as some.func() then the object is not passed as the first argument, in which case we would also need to define some.func_PassOverHookableObject function which must return \boolean true. This tells the hook system to not supply the object as the first argument if the function is apart of an object in the first place. Generic function hooks do not store an object and so do not have to worry about defining that additional property on its own function.

FrameworkZ.Foundation:ExecuteModuleHooks(hookName, ...)

method
Execute module hooks.

Parameters

hookName 📝 string
The name of the hook.

FrameworkZ.Foundation:ExecutePluginHooks(hookName, ...)

method
Execute plugin hooks.

Parameters

hookName 📝 string
The name of the hook.

FrameworkZ.Foundation:Fire(key, data, arguments)

method
Fires a callback for a key. This will call the callback for the key with the value supplied.

Parameters

key 📝 string
The key to fire the callback for. Use a \table to fire the callback for nested values. \see FrameworkZ.Foundation::Subscribe for an example on how to supply a table as a key.
data 📋 table
The standard data to pass to the callback. Generally contains diagnostic information.
arguments 📋 table
The values to pass to the callback. This can be any type of values stored in the table.

Returns

📋 table
A table of return values from the callbacks. The keys are the IDs of the callbacks and the values are the return values from the callbacks.

FrameworkZ.Foundation:GetChannel(key)

method
Get the channel for a key. This will return the channel data for the key.

Parameters

key 📝 string
or \table The key to use for the channel. Use a table to create nested channels. \see FrameworkZ.Foundation::Subscribe for an example on how to supply a table as a key.

Returns

📋 table
The channel data for the key.

FrameworkZ.Foundation:GetChannelMeta(key)

method
Get the meta data for a channel. This will return the meta data for the key.

Parameters

key 📝 string
or \table The key to use for the channel. Use a table to create nested channels. \see FrameworkZ.Foundation::Subscribe for an example on how to supply a table as a key.

Returns

📋 table
The meta data for the key.

FrameworkZ.Foundation:GetData(isoPlayer, namespace, keys, subscriptionID, callback)

method
Gets a value from a namespace by key(s).

Parameters

isoPlayer 📦 object
(Optional) The player to get the value for. This is only used on the client to send a request to the server.
namespace 📝 string
The namespace to get the value from.
keys 📝 string
or \table The key(s) to get the value for. Supplying a table will do a lookup through all keys and get value at the last index.
subscriptionID 📝 string
(Optional) A unique identifier for the subscription to be fired server-side after the value has been retrieved.
callback ⚡ function
(Optional) A callback function to call after the value is retrieved. This is only used on the client to handle the response from the server.

Returns

🌟 any
(except \function) The value for the key in the namespace, or false if the namespace or key does not exist. Server-side only.

📝 Notes

If called on the client, the value may only be accessed in the callback immediately, or later after data has synchronized.

FrameworkZ.Foundation:GetLocalData(namespace, keys)

method
Gets data from local storage using namespace and keys.

Parameters

namespace 📝 string
The namespace to retrieve data from.
keys 📝 string
or \table The key(s) to retrieve. If table, performs nested lookup.

Returns

🏷️ mixed
The retrieved data, or an error code if not found.

FrameworkZ.Foundation:GetModule(moduleName)

method
Get a module by name.

Parameters

moduleName 📝 string
The name of the module.

Returns

📦 object
The module object or \false if the module was not found.

FrameworkZ.Foundation:GetModuleMetaObject(moduleName)

method
Get a module's meta object stored on a module. Not every module will have a meta object. This is a very specific use case and is used for getting instantiable objects such as PLAYER objects or CHARACTER objects.

Parameters

moduleName 📝 string
The name of the module.

Returns

📦 object
The meta object stored on the module or false if nothing was found.

FrameworkZ.Foundation:GetNamespace(namespace)

method
Retrieves the entire namespace table.

Parameters

namespace 📝 string
The namespace to retrieve.

Returns

📋 table
The namespace table or nil if not found.

FrameworkZ.Foundation:GetNestedValue(root, path)

method
Get a nested value from a table using a path. This is used to get values from nested tables.

Parameters

root 📋 table
The root table to get the value from.
path 📋 table
The path to the value. This is a table of keys to traverse the nested tables.

Returns

🏷️ mixed
The value at the end of the path, or nil if the path does not exist.

📝 Notes

Example path argument: {"key", "subkey"} == root["key"]["subkey"]

FrameworkZ.Foundation:GetSubscribers(key)

method
Get the subscribers for a key. This will return the subscribers for the key.

Parameters

key 📝 string
The key to get the subscribers for. Use a \table to get the subscribers for nested values. \see FrameworkZ.Foundation::Subscribe for an example on how to supply a table as a key.

Returns

📋 table
The subscribers for the key.

FrameworkZ.Foundation:GetVersion()

method
Get the version of FrameworkZ Foundation.

Returns

📝 string
The version of the FrameworkZ Foundation.

FrameworkZ.Foundation:HasChannel(key)

method
Check if a channel exists for a key. This will return true if the channel exists, false otherwise.

Parameters

key 📝 string
or \table The key to use for the channel. Use a table to create nested channels. \see FrameworkZ.Foundation::Subscribe for an example on how to supply a table as a key.

Returns

✅ boolean
True if the channel exists, false otherwise.

FrameworkZ.Foundation:HasSubscription(key, id)

method
Check if a subscription exists for a key. This will return true if the subscription exists, false otherwise.

Parameters

key 📝 string
The key to check for. Use a \table to check for nested values. \see FrameworkZ.Foundation::Subscribe for an example on how to supply a table as a key.
id 📝 string
The ID of the function callback being checked.

Returns

✅ boolean
True if the subscription exists, false otherwise.

FrameworkZ.Foundation:Initialize()

method
Initializes the FrameworkZ Foundation system by setting up event handlers and registering them with the Project Zomboid event system.

📝 Notes

The LoadGridSquare event is not added to the hook system for performance reasons, as it is called very frequently.

This function wraps the Project Zomboid Events system to integrate with the FrameworkZ hook system, allowing all foundation events to be processed through the hook mechanism.

FrameworkZ.Foundation:InitializeClient(isoPlayer)

method
Main client initialization function. Sets up player state and communicates with the server.

Parameters

isoPlayer 📦 object
The player object being initialized.

FrameworkZ.Foundation:InitializePlayer(isoPlayer, playerData, charactersData)

method
Initializes a player with framework data and sets up their initial state.

Parameters

isoPlayer 📦 object
The player's ISO object.
playerData 📋 table
(Optional) Existing player data for restoration.
charactersData 📋 table
(Optional) Existing character data for restoration.

Returns

✅ boolean
\table, \table Returns success status, player data, and character data.

FrameworkZ.Foundation:LogChannels()

method
Log all channels and their subscribers to the console. This is useful for debugging and understanding the network system.

FrameworkZ.Foundation:NewModule(moduleObject, moduleName)

method
Create a new module for the FrameworkZ framework.

Parameters

moduleObject 📦 object
The object to use as the module.
moduleName 📝 string
The name of the module.

Returns

📦 object
The new module.

FrameworkZ.Foundation:OnClientCommand(module, command, isoPlayer, arguments)

method
Handles incoming commands from the client on the server.

Parameters

module 📝 string
The name of the module that sent the command. This should match the NetworksName defined in FrameworkZ.Foundation.NetworksName.
command 📝 string
The command that was sent by the client.
isoPlayer 📦 object
The player that sent the command. This is the player object that sent the command.
arguments 📋 table
The arguments that were sent with the command. This contains the data needed to process the command.

📝 Notes

This function is called on the server when a client sends a command to the server. It processes the command and sends a response back to the client using the networking system.

FrameworkZ.Foundation:OnGameStart()

method
Called when the game starts. Executes the OnGameStart function for all modules.

FrameworkZ.Foundation:OnServerCommand(module, command, arguments)

method
Handles incoming commands from the server on the client.

Parameters

module 📝 string
The name of the module that sent the command. This should match the NetworksName defined in FrameworkZ.Foundation.NetworksName.
command 📝 string
The command that was sent by the server.
arguments 📋 table
The arguments that were sent with the command. This contains the data needed to process the command.

📝 Notes

This function is called on the client when the server sends a command to the client. It processes the command and sends a response back to the server using the networking system.

FrameworkZ.Foundation:OnServerStarted()

method
Callback for when the server starts. Initializes server-side tick systems.

FrameworkZ.Foundation:PathToString(path)

method
Convert a path to a string. This is used to convert a table path to a string path.

Parameters

path 📝 string
or \table The path to convert. If a string is supplied, it will be returned as is. If a table is supplied, it will be concatenated with dots.

Returns

📝 string
The string representation of the path.

FrameworkZ.Foundation:PostInitializeClient(player)

method
Post-initialization phase that completes the client setup and shows success notification.

Parameters

player 📦 object
The framework player object that has been initialized.

FrameworkZ.Foundation:PreInitializeClient(isoPlayer)

method
Pre-initialization phase for client setup. Sets up the UI and executes module hooks.

Parameters

isoPlayer 📦 object
The player object being initialized.

FrameworkZ.Foundation:ProcessSaveableData(object, ignoreList, encodeList)

method
Processes an object to extract saveable data, filtering out functions and handling nested objects.

Parameters

object 📋 table
The object to process for saving.
ignoreList 📋 table
List of keys to ignore during processing.
encodeList 📋 table
List of keys that should be encoded using their GetSaveableData method.

Returns

📋 table
The processed saveable data.

FrameworkZ.Foundation:QueueBatchSync(isoPlayer, namespace, key)

method
Queue a key in a namespace for batch synchronization.

Parameters

isoPlayer 📦 object
The player to queue sync for.
namespace 📝 string
The namespace containing the data.
key 📝 string
The key to sync.

FrameworkZ.Foundation:RegisterFramework()

method
Register FrameworkZ. This is called after framework definition.

FrameworkZ.Foundation:RegisterFrameworkHandler()

method
Register hook handlers for the framework.

FrameworkZ.Foundation:RegisterGamemodeHandler(gamemode)

method
Register hook handlers for the gamemode.

Parameters

gamemode 📋 table
The gamemode table containing the functions.

FrameworkZ.Foundation:RegisterGenericHandler()

method
Register generic hook handlers that don't belong to a specific object.

FrameworkZ.Foundation:RegisterHandler(hookName, handler, object, functionName, category)

method
Register a handler for a hook.

Parameters

hookName 📝 string
The name of the hook.
handler ⚡ function
The function to call when the hook is executed.
object (optional) 📋 table
The object containing the function.
functionName (optional) 📝 string
The name of the function to call.
category 📝 string
The category of the hook (framework, module, plugin, generic). Defaults to HOOK_CATEGORY_GENERIC if not specified.

FrameworkZ.Foundation:RegisterHandlers(objectOrHandlers, category)

method
Register handlers for a specific category.

Parameters

objectOrHandlers 📋 table
The object containing the functions, or nil for generic handlers.
category 📝 string
The category of the hook (framework, module, plugin, generic). Defaults to HOOK_CATEGORY_GENERIC if not specified.

FrameworkZ.Foundation:RegisterModule(module)

method
Register a module for FrameworkZ. This is called after module definition.

Parameters

module 📦 object
The module to register.

FrameworkZ.Foundation:RegisterModuleHandler(module)

method
Register hook handlers for a module.

Parameters

module 📋 table
The module table containing the functions.

FrameworkZ.Foundation:RegisterNamespace(name)

method
Registers a storage namespace, e.g., "Players"

Parameters

name 📝 string
The name of the namespace to register.

📝 Notes

This must be used in the shared scope within an OnInitGlobalModData function.

FrameworkZ.Foundation:RegisterPluginHandler(plugin)

method
Register hook handlers for a plugin.

Parameters

plugin 📋 table
The plugin table containing the functions.

FrameworkZ.Foundation:RemoveChannel(key)

method
Remove a channel from the network system. This will remove all subscribers and meta data for the channel.

Parameters

key 📝 string
or \table The key to use for the channel. Use a table to create nested channels. \see FrameworkZ.Foundation::Subscribe for an example on how to supply a table as a key.

FrameworkZ.Foundation:RemoveData(namespace, key)

method
Removes a key from a namespace and broadcasts removal.

Parameters

namespace 📝 string
The namespace to remove from.
key 📝 string
The key to remove.

FrameworkZ.Foundation:RemoveHookHandler(hookName, category)

method
Remove a hook handler from the list.

Parameters

hookName 📝 string
The name of the hook handler to remove.
category 📝 string
The category of the hook (framework, module, plugin, generic). Defaults to HOOK_CATEGORY_GENERIC if not specified.

FrameworkZ.Foundation:RestoreData(isoPlayer, command, namespace, keys, callback)

method
Restores data from storage for client-server synchronization.

Parameters

isoPlayer 📦 object
The player object.
command 📝 string
The command identifier.
namespace 📝 string
The namespace to restore from.
keys 📝 string
or \table The key(s) to restore.
callback ⚡ function
Callback function to handle the restored data.

Returns

✅ boolean
Returns true if successful on server, varies on client.

FrameworkZ.Foundation:RestorePlayer(isoPlayer, player, username, playerData, charactersData)

method
Restores player data from storage or creates new data if none exists.

Parameters

isoPlayer 📦 object
The player's ISO object.
player 📦 object
The framework player object.
username 📝 string
The player's username.
playerData 📋 table
(Optional) Existing player data on client-side.
charactersData 📋 table
(Optional) Existing character data on client-side.

Returns

📋 table
\table The player data and character data, or false if new.

FrameworkZ.Foundation:SaveData(isoPlayer)

method
Saves all namespace data to persistent storage.

Parameters

isoPlayer 📦 object
(Optional) The player object. Used on client to send request to server.

FrameworkZ.Foundation:SaveNamespace(isoPlayer, namespace)

method
Saves a specific namespace to persistent storage.

Parameters

isoPlayer 📦 object
(Optional) The player object. Used on client to send request to server.
namespace 📝 string
The namespace to save.

FrameworkZ.Foundation:SendFire(isoPlayer, subscriptionID, callback, ...)

method
Sends a fire event to the server or client. This is used to send events to subscribers.

Parameters

isoPlayer 📦 object
The player sending the fire event. If nil, the event will be fired but no confirmation will be sent back (send and forget).
subscriptionID 📝 string
The ID of the subscription to fire. This is the key used to subscribe to the event. It's recommended to use a string matching your function's callback name in a unique way when adding a subscription.
callback ⚡ function
The callback to call when the server confirms the fire event. This is optional and can be nil if you don't need confirmation.

Returns

📝 string
The request ID for the fire event. This can be used to track the request and get confirmation later.

FrameworkZ.Foundation:SendGet(key, callback, callbackID, broadcast, ...)

method
Sends a get request to the server.

Parameters

key 🏷️ mixed
The key to get. Does not support getting functions.
callback ⚡ function
The callback to call on the client when the server returns the value.
callbackID 📝 string
The key to use for the callback on the server after getting the value.
broadcast ✅ boolean
Whether to broadcast the get callback to all clients.

FrameworkZ.Foundation:SendSet(key, value, callback, callbackID, broadcast)

method
Sends a set request to the server.

Parameters

key 📝 string
or \table The key to set. Use a table to set nested values. \note Example key argument as a table: {"key", "subkey"} == _G["key"]["subkey"] or _G.key.subkey on lookup when setting.
value 🏷️ mixed
The value to set. Does not support functions.
callback ⚡ function
The callback to call on the client when the server confirms the set.
callbackID 📝 string
The key to use for the callback on the server after setting the value.
broadcast ✅ boolean
Whether to broadcast the set callback to all clients.

FrameworkZ.Foundation:ServerTick()

method
Server tick handler that manages periodic data saving.

FrameworkZ.Foundation:SetData(isoPlayer, namespace, keys, value, subscriptionID, broadcast, callback)

method
Sets a value in a namespace and (optionally) broadcasts to all clients.

Parameters

isoPlayer 📦 object
(Optional when called server-side only) The player to set the value for. This is only used on the client to send a request to the server.
namespace 📝 string
The namespace to set the value in.
keys 📝 string
or \table The key(s) to set the value for. Supplying a table will do a lookup through all keys and set value at the last index.
value 🌟 any
(except \function) The value to set.
subscriptionID 📝 string
(Optional) A unique identifier for the subscription to be fired server-side after the value has been set.
broadcast ✅ boolean
(Optional) Whether or not to broadcast the value to all clients.
callback ⚡ function
(Optional) A callback function to call after the value is set. This is only used on the client to handle the response from the server.

Returns

✅ boolean
Whether or not the value was set successfully. Server-side only.

📝 Notes

If called on the client, the value may only be accessed in the callback immediately, or later after data has synchronized.

FrameworkZ.Foundation:SetLocalData(namespace, keys, value)

method
Sets data in local storage using namespace and keys.

Parameters

namespace 📝 string
The namespace to store data in.
keys 📝 string
or \table The key(s) to set. If table, performs nested assignment.
value 🏷️ mixed
The value to store.

Returns

✅ boolean
Returns true if successful, false otherwise.

FrameworkZ.Foundation:SetNestedValue(root, path, value)

method
Set a nested value in a table using a path. This is used to set values in nested tables.

Parameters

root 📋 table
The root table to set the value in.
path 📋 table
The path to the value. This is a table of keys to traverse the nested tables.
value 🏷️ mixed
The value to set at the end of the path.

Returns

🏷️ mixed
The value that was set at the end of the path.

📝 Notes

Example path argument: {"key", "subkey"} == root["key"]["subkey"] = value

FrameworkZ.Foundation:StartBatchSync(isoPlayer, interval, onComplete)

method
Begin processing the queued keys for a player with a timer-based batch system.

Parameters

isoPlayer 📦 object
The player to sync data for.
interval 🔢 number
(Optional) The interval between sync operations. Default: 0.1 seconds.
onComplete ⚡ function
(Optional) Callback to call when sync is complete.

FrameworkZ.Foundation:StartServerTick()

method
Starts the server tick system that manages timers and periodic operations.

FrameworkZ.Foundation:Subscribe(key, idOrCallback, maybeCallback)

method
Subscribes to a key to listen for changes with the first three arguments supplied, or can be used for sending/receiving fire events with the first two arguments supplied.

Parameters

key 📝 string
The key to subscribe to. Use a \table to subscribe to nested values. \note Example key argument as a table: {"key", "subkey"} == _G["key"]["subkey"] or _G.key.subkey on lookup when subscribing.
idOrCallback 📝 string
or \function The ID of the function callback being added, or the callback function itself. If a string is supplied, it will be used as the ID for the callback.
maybeCallback ⚡ function
The callback function to call when the key changes. This is optional if the first argument is a function.

Returns

⚡ function
The callback function that was added. This can be used to unsubscribe later.

FrameworkZ.Foundation:SyncToPlayer(isoPlayer, namespace, key)

method
Sends a specific key to a specific player.

Parameters

isoPlayer 📦 object
The player to send the data to.
namespace 📝 string
The namespace containing the data.
key 📝 string
The key to send.

FrameworkZ.Foundation:TeleportToLimbo(isoPlayer)

method
Teleports a player to the configured limbo location.

Parameters

isoPlayer 📦 object
The player object to teleport.

Returns

✅ boolean
Returns true if successful, false if the player object is invalid.

FrameworkZ.Foundation:UnregisterFrameworkHandler()

method
Unregister hook handlers for the framework.

FrameworkZ.Foundation:UnregisterGamemodeHandler(gamemode)

method
Unregister hook handlers for the gamemode.

Parameters

gamemode 📋 table
The gamemode table containing the functions.

FrameworkZ.Foundation:UnregisterGenericHandler()

method
Unregister generic hook handlers that don't belong to a specific object.

FrameworkZ.Foundation:UnregisterHandler(hookName, handler, object, functionName, category)

method
Unregister a handler from a hook.

Parameters

hookName 📝 string
The name of the hook.
handler ⚡ function
The function to unregister.
object 📋 table
(Optional) The object containing the function.
functionName 📝 string
(Optional) The name of the function to unregister.
category 📝 string
The category of the hook (framework, module, plugin, generic). Defaults to HOOK_CATEGORY_GENERIC if not specified.

FrameworkZ.Foundation:UnregisterHandlers(objectOrHandlers, category)

method
Unregister handlers for a specific category.

Parameters

objectOrHandlers 📋 table
The object containing the functions, or nil for generic handlers.
category 📝 string
The category of the hook (framework, module, plugin, generic). Defaults to HOOK_CATEGORY_GENERIC if not specified.

FrameworkZ.Foundation:UnregisterModuleHandler(module)

method
Unregister hook handlers for a module.

Parameters

module 📋 table
The module table containing the functions.

FrameworkZ.Foundation:UnregisterPluginHandler(plugin)

method
Unregister hook handlers for a plugin.

Parameters

plugin 📋 table
The plugin table containing the functions.

FrameworkZ.Foundation:Unsubscribe(key, id)

method
Unsubscribes from a key. This will remove the callback from the channel.

Parameters

key 📝 string
The key to unsubscribe from. Use a \table to unsubscribe from nested values. \see FrameworkZ.Foundation::Subscribe for an example on how to supply a table as a key.
id 🏷️ sting
The ID of the function callback being removed. Default for fire events: "__default"

FrameworkZ.Foundation:Watch(key, id, callback)

method
Subscribes and fires callback immediately if the value is already set. Useful for UIs.

Parameters

key 📝 string
or \table The key to watch. Use a table to watch nested values. \see FrameworkZ.Foundation::Subscribe for an example on how to supply a table as a key.
id 📝 string
The ID of the function callback being added.
callback ⚡ function
The callback to call when the key changes.

Functions

11

FrameworkZ.Foundation.New()

function
Create a new instance of the FrameworkZ framework.

Returns

📋 table
The new instance of the FrameworkZ framework.

FrameworkZ.Foundation.OnGetData(data, namespace, keys, subscriptionID)

function
Network callback for getting data from storage.

Parameters

data 📋 table
The request data.
namespace 📝 string
The namespace to retrieve from.
keys 📝 string
or \table The key(s) to retrieve.
subscriptionID 📝 string
(Optional) Subscription ID for callback.

Returns

🏷️ mixed
The retrieved value.

FrameworkZ.Foundation.OnInitializePlayer(data)

function undocumented
No documentation available

Parameters (inferred)

data unknown
Parameter inferred from function signature

Returns (inferred)

⭕ void
Return type inferred from function name pattern

FrameworkZ.Foundation.OnRemoveData(data)

function
Client receives key removal broadcast.

Parameters

data 📋 table
The removal data containing namespace and key.

FrameworkZ.Foundation.OnSaveData(data)

function undocumented
No documentation available

Parameters (inferred)

data unknown
Parameter inferred from function signature

FrameworkZ.Foundation.OnSaveNamespace(data)

function
Client-side callback for saving a specific namespace.

Parameters

data 📋 table
The data containing the isoPlayer and namespace.

FrameworkZ.Foundation.OnSaveNamespace(data, namespace)

function
Server-side callback for saving a specific namespace.

Parameters

data 📋 table
The data containing the isoPlayer object.
namespace 📝 string
The namespace to save.

FrameworkZ.Foundation.OnSetData(data, namespace, keys, value, subscriptionID, broadcast)

function
Network callback for setting data in storage.

Parameters

data 📋 table
The request data.
namespace 📝 string
The namespace to store in.
keys 📝 string
or \table The key(s) to set.
value 🏷️ mixed
The value to store.
subscriptionID 📝 string
(Optional) Subscription ID for callback.
broadcast ✅ boolean
Whether to broadcast the change.

Returns

✅ boolean
Success status.

FrameworkZ.Foundation.OnSync(data)

function
Server-side response to client sync request.

Parameters

data 📋 table
The sync request data containing namespace and key.

Returns

📋 table
Returns a table with namespace, key, and value if successful.

FrameworkZ.Foundation.OnSyncBroadcast(data)

function
Client receives sync data from broadcast.

Parameters

data 📋 table
The broadcast data containing namespace, key, and value.

FrameworkZ.Foundation.OnTeleportToLimbo(data)

function
Network callback function for teleporting a player to the limbo area.

Parameters

data 📋 table
The data containing the isoPlayer object.

Returns

✅ boolean
Returns true if successful, false otherwise.