Cod3xDocs
example

Publish a Small Interface

A minimal OpenMW interface shape with private implementation state.

Keep implementation state private and export only the operations consumers need.

---@omw-context player

local enabled = true

local function isEnabled()
  return enabled
end

local function setEnabled(value)
  assert(type(value) == 'boolean', 'value must be boolean')
  enabled = value
end

return {
  interfaceName = 'ExampleFeature',
  interface = {
    isEnabled = isEnabled,
    setEnabled = setEnabled,
  },
}

For a shared/public mod API, add LuaLS metadata for the interface and document version/ownership expectations.

See API and Interface Design and Built-In Interfaces.