tac.core.extension_loader v1.0.1

Provides robust extension loading with dependency management, error handling, and graceful degradation. Supports extension metadata, version checking, and load order resolution based on dependencies.

Author: Twijn • License: MIT
View on GitHub →

Examples

-- Load extensions (usually done in tac/init.lua):
local ExtensionLoader = require("tac.core.extension_loader")
local loader = ExtensionLoader.new(tacInstance)

-- Load all extensions from directory
local success, errors = loader.loadFromDirectory("tac/extensions")

-- Check loaded extensions
local loaded = loader.getLoadedExtensions()
for name, metadata in pairs(loaded) do
    print(name .. " v" .. metadata.version)
end

-- Load specific extension
local ext, err = loader.loadExtension("shopk_access", "tac/extensions/shopk_access.lua")

Functions

ExtensionLoader.create(tacInstance)

View source

Create extension loader for TAC instance Returns a loader interface with methods for discovering, loading, and managing extensions.

Parameters:
Returns: table Loader interface with load methods

loader.loadFromDirectory(options)

View source

Load extensions from directory Discovers and loads all extensions from the extensions directory, respecting dependencies and handling errors gracefully. - directory (string): Extension directory path (default: "tac/extensions") - skipPrefixes (table): Array of filename prefixes to skip (default: {"_", "disabled_"}) - silent (boolean): Suppress output messages (default: false) - loaded (table): Array of successfully loaded extension names - failed (table): Array of objects with name and error for failed extensions - skipped (table): Array of skipped extension names

Parameters:
Returns: table Results with fields:

loader.loadExtension(extensionName, options)

View source

Load a specific extension by name Loads a single extension from the extensions directory. - directory (string): Extension directory path (default: "tac/extensions") - silent (boolean): Suppress output messages (default: false)

Parameters:
Returns: string|nil Error message if loading failed

loader.getLoadedExtensions()

View source

Get information about loaded extensions Returns metadata for all currently loaded extensions.

Returns: table Array of extension metadata objects