H3lp Yours3lfDocs
api

uiSnapshot

Capture deterministic, bounded text snapshots of OpenMW UI layouts.

require 'scripts.s3.uiSnapshot' → uiSnapshot

Use uiSnapshot when a UI bug needs evidence rather than another guess at the layout. It turns a layout or UI element into deterministic text or fresh plain Lua data.

Capture a layout

local ui = require 'openmw.ui'
local uiSnapshot = require 'scripts.s3.uiSnapshot'
local util = require 'openmw.util'

local element = ui.create {
  type = ui.TYPE.Text,
  layer = 'HUD',
  props = {
    text = 'Loading...',
    relativeSize = util.vector2(0.4, 0.05),
  },
}

print(uiSnapshot.format(element))

Options

local snapshot = uiSnapshot.capture(element, {
  maxDepth = 6,
  maxChildren = 32,
  maxString = 80,
  includeEvents = false,
  includeUserData = true,
  vectorMode = 'placeholder',
})
OptionBehavior
maxDepthMaximum nested table/layout depth; default 8.
maxChildrenMaximum numeric content children; default 128.
maxStringMaximum string length before a truncation marker; default 160.
includeFunctionsInclude stable { __type = 'function' } placeholders; default false.
includeEventsInclude event tables and callback placeholders; default false.
includeUserDataInclude userData; default false.
vectorMode'fields' records vector/color components; 'placeholder' records only their type.
sortKeysSort non-layout keys for stable output; default true.

Depth, child, and string limits produce truncation markers. Cycles and repeated references are reported instead of recursed into; unsupported userdata becomes a type marker.

Output forms

CallResult
fromLayout(layout, options?)Fresh plain table snapshot.
fromElement(element, options?)Snapshot or { __snapshot = 'invalidElement', reason = ... }.
capture(value, options?)Element snapshot when readable; otherwise value/layout snapshot.
lines(value, options?)Fresh deterministic text-line array.
format(value, options?)Newline-separated deterministic text.

fromElement does not raise when a destroyed or invalid element rejects a layout read. Use lines for custom prefixes and table forms for field assertions. Capture on demand, not from a high-frequency callback; returned values are snapshots and do not update with later UI mutations.