S3maphoreDocs
interface

I.S3maphore

The player-scoped interface for controlling and inspecting S3maphore.

S3maphore registers I.S3maphore in the OpenMW Player context. Other scripts can obtain it with require 'openmw.interfaces' after the player script has initialized.

local I = require 'openmw.interfaces'
local S3maphore = I.S3maphore

Playback control

MemberSignatureBehavior
skipTrackfun()Stops the current track. Normal resolution chooses the next track or playlist.
playSpecialTrackfun(trackPath, reason?)Plays one VFS track as a one-off special track.
overrideMusicEnabledfun(enabled?)Sets whether music playback is enabled. With nil, toggles the current value.
getEnabledfun() → booleanReturns whether music playback is enabled.
setPlaylistActivefun(id, state)Enables or disables a registered playlist.
getDeathTrackfun() → stringReturns the currently configured death-track VFS path.
setDeathTrackfun(path: string)Sets the death-track VFS path when the file exists.
resetDeathTrackfun()Restores the default death-track path.

Inspection

MemberSignatureBehavior
getCurrentPlaylistfun() → ReadOnlyTable?Read-only snapshot of the playlist that supplied the current track, or nil.
getCurrentTrackfun() → string?Current VFS track path, or nil.
getCurrentTrackInfofun() → PlaylistMetadata?, TrackMetadata?Metadata for the current playlist and track. Returns nil, nil when stopped. See Playlist and Track Metadata.
getRegisteredPlaylistsfun() → ReadOnlyTableRead-only map of registered playlist definitions.
listPlaylistFilesfun() → ReadOnlyTableRead-only list of recognized .lua playlist files under Playlists/.
listPlaylistsByPriorityfun() → stringFormatted priority listing, mainly for the luap console.
getStatefun() → ReadOnlyTableRead-only PlaylistState snapshot.
silenceTimefun() → numberRemaining silence interval in seconds.

Registration and callbacks

MemberSignatureBehavior
registerPlaylistfun(playlist: S3maphorePlaylist)Initializes missing fields, discovers folder-derived tracks, assigns registration order, persists activation state, and sorts the playlist into its priority group.
addTrackChangedHandlerfun(handler: TrackChangedHandler)Registers a callback receiving S3maphorePlaybackChangeEventData whenever S3maphore accepts a track change.

Handlers should return quickly and treat event data as read-only.

State, rules, and metadata

MemberMeaning
stateLive read-only PlaylistState proxy.
rulesComplete PlaylistRules table.
playlistMetadataMetadata registry for playlist names and track information. See Playlist and Track Metadata.
playlistTimeOfDay()Current TimeOfDay bucket.
isInCombat()Raw combat state, independent of BattleEnabled.
actorIsInCombat(actorId)Raw combat tracking query for an actor ID.
getCombatTargets()Live read-only array of current combat targets.

Constants

S3maphore.const is read-only and contains:

TableValues
STATEDied, Disabled, NoPlaylist, PlaylistChanged, SpecialTrackPlaying, TrackChanged
TIME_MAPnight, morning, afternoon, evening by numeric time bucket
INTERRUPTMe = 0, Other = 1, Never = 2, Override = 3
STATE_FLAGSTOD = 1, MOVEMENT = 2, SPELL_SCHOOL = 4, STANCE = 8

Example: inspect and control playback

local I = require 'openmw.interfaces'
local S3maphore = I.S3maphore

local current = S3maphore.getCurrentTrack()
if current then
    print(('Playing %s'):format(current))
end

S3maphore.addTrackChangedHandler(function(event)
    print(('S3maphore selected %s from %s'):format(event.trackName, event.playlistId))
end)

S3maphore.setPlaylistActive('my-mod/storm-explore', true)

For death-track control, use the dedicated Death Track reference rather than playSpecialTrack.