Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Presentations

The web client supports server-driven UI panels and windows via the present() builtin. Presentations are how MOO code asks the client to display structured UI elements beyond plain text output, delivered through moor-web-host.

The present() Builtin

See also: Builtin Reference

present(player, id, content_type, target, content, attributes)
present(player, id)  // Dismiss presentation
ParameterDescription
playerThe player object to show the presentation to
idUnique identifier for this presentation (used to update or dismiss)
content_typeMIME type for content (usually "text/plain" or "text/html")
targetWhere to show the presentation (see Targets below)
contentOptional content string
attributesList of {key, value} pairs for additional options

To dismiss a presentation, call present() with only player and id.

Targets and Placement

The client maps semantic targets to dock positions based on screen size:

Dock Targets

TargetDesktop PositionMobile PositionUse Case
navigationLeft dockTopMaps, compass, location info
communicationLeft dockTopChat panels, who lists
inventoryRight dockBottomPlayer inventory
statusRight dockTopHealth, stats, timers
toolsRight dockBottomQuick actions, utilities
helpRight dockBottomHelp panels, hints

Floating Targets

TargetBehaviorUse Case
windowFloating window, draggableGeneral-purpose popups
object-browserFloating or dockedObject inspection

Editor Targets

TargetOpens
verb-editorVerb code editor
property-editorProperty text editor
property-value-editorStructured value editor
text-editorLong-form text editor

Dialog Targets

TargetPurpose
profile-setupPlayer profile configuration

Common Attributes

Attributes are passed as a list of {key, value} pairs:

AttributeUsed ByDescription
titleAllWindow/panel title
nameAllAlternative to title
objectEditors, browserObject reference (e.g., "#123")
verbverb-editorVerb name to edit
propertyProperty editorsProperty name to edit
contentEditorsInitial content
fieldsprofile-setupComma-separated field names

Examples

Open a Verb Editor

present(player, "edit-look", "text/plain", "verb-editor", "",
        {{"object", tostr(this)}, {"verb", "look"}, {"title", "Edit look verb"}});

Open a Property Editor

present(player, "edit-desc", "text/plain", "property-editor", "",
        {{"object", tostr(this)}, {"property", "description"}});

Show Object Browser Focused on an Object

present(player, "inspect", "text/plain", "object-browser", "",
        {{"object", tostr(target_obj)}});

Show a Status Panel

content = $format.block:mk(
    "Health: " + tostr(player.health) + "/" + tostr(player.max_health),
    "Mana: " + tostr(player.mana) + "/" + tostr(player.max_mana)
);
present(player, "status-panel", "text/html", "status",
        content:compose(player, 'text_html), {{"title", "Status"}});

Show an Inventory Panel

items = {};
for item in (player.contents)
    items = {@items, item.name};
endfor
content = $format.list:mk(items):compose(player, 'text_html);
present(player, "inv-panel", "text/html", "inventory", content,
        {{"title", "Inventory"}});

Update an Existing Presentation

Calling present() with the same id updates the content:

// Initial presentation
present(player, "timer", "text/plain", "status", "Time: 60", {{"title", "Countdown"}});

// Update it later
present(player, "timer", "text/plain", "status", "Time: 30", {{"title", "Countdown"}});

Dismiss a Presentation

present(player, "timer");  // Removes the "timer" presentation

Profile Setup Dialog

present(player, "profile-setup", "text/plain", "profile-setup", "",
        {{"title", "Set up your profile"}, {"fields", "pronouns,description,picture"}});

The fields attribute controls which profile fields are shown:

  • pronouns - Pronoun selection
  • description - Character description
  • picture - Profile picture upload

Responsive Behavior

The client automatically adjusts presentation placement based on screen size:

  • Desktop (>768px): Dock panels appear in sidebars; floating windows can be dragged
  • Mobile (≤768px): Dock panels stack vertically; editors open in full-screen modal mode

Programmers should design presentations to work well at both sizes. Use semantic targets (inventory, status, etc.) rather than assuming specific screen positions.