0Pricing
Lua Academy · Lesson

Plugin Discovery and Loading

Scan directories for plugin files and load them with require or loadfile.

What Is a Plugin Architecture?

A plugin architecture allows third-party code to extend an application without modifying its core. Lua's require and dynamic loading make this natural.

Plugin Discovery by Convention

Scan a directory for *.lua files matching a naming convention, then load each as a plugin.

local function discoverPlugins(dir)
  local plugins = {}
  -- platform-specific dir scan; here a mock example
  for _, name in ipairs({"logger", "cache", "auth"}) do
    local ok, mod = pcall(require, dir .. "." .. name)
    if ok then plugins[name] = mod end
  end
  return plugins
end

All lessons in this course

  1. Plugin Discovery and Loading
  2. Plugin API and Hook System
  3. Sandboxing Plugin Execution
  4. Versioning and Dependency Management
← Back to Lua Academy