This file demonstrates how to create a TAC extension. Extensions can register commands, add hooks to TAC events, and provide custom functionality.
View on GitHub →-- To use this extension from another extension:
function MyExtension.init(tac)
-- Load the example extension
local example = tac.require("example")
-- Call exported methods
local stats = example.getStats()
print("Processed " .. stats.processedCount .. " messages")
-- Use optional dependencies
local result = example.useOptionalExtension()
-- Process a message
example.processMessage("Hello, TAC!")
end
ExampleExtension.init(tac)Initialize the extension This function is called when the extension is loaded by TAC. Use this to: - Register commands with tac.registerCommand() - Add hooks with tac.addHook() - Register background processes with tac.registerBackgroundProcess() - Access TAC settings, cards, doors, etc. - registerCommand(name, commandDef): Register a new command - registerExtension(name, extension): Register an extension - addHook(hookName, callback): Add a hook callback - registerBackgroundProcess(name, fn): Register a background process - settings: Persistent settings storage - cards: Persistent card storage - doors: Persistent door storage - logger: Logger instance
tac (table): The TAC instance with methods:ExampleExtension.customFunction()Custom function that can be called by other extensions Demonstrates how extensions can provide APIs for inter-extension communication.
ExampleExtension.onCardCreated(cardData)Hook for card creation events This function will be called when cards are created (if hooked into TAC). Can be used to extend or validate card data.
cardData (table): The card data being createdExampleExtension.useOptionalExtension(tac)Example of safely requiring another extension Demonstrates how to check if an extension is loaded and access its functionality. This is useful for optional dependencies or inter-extension communication.
tac (table): The TAC instanceExampleExtension.processMessage(message)Example API method that other extensions can call Shows how to export methods that other extensions can use.
message (string): Message to processExampleExtension.getStats()Get extension statistics Example of exposing data through the extension API.