Quick navigation

Go to

Input & controls

Clipboard API and transform commands

The write-only client clipboard API, the clipboard.write permission, failure reasons, and the built-in /pos and /rot transform commands.

2 min read345 wordsMarkdown
On this page4 sections

Copy text to the operating-system clipboard with a client resource. The API is write-only and is intended for explicit actions such as copying coordinates, IDs or configuration snippets.

Manifest permission

Declare clipboard.write in the client resource that performs the write:

resource "my_tools"
version "1.0.0"

client_script "client/main.lua"
permission "clipboard.write"

The permission belongs to the resource whose client VM calls the API. A server resource cannot write directly to a player's clipboard.

Write text

local copied, reason = Open77.clipboard.setText(
    "position = { x = 1660.068359, y = -723.649170, z = 50.512436 }"
)

if not copied then
    print("Clipboard write failed: " .. tostring(reason))
end

Open77.clipboard.setText(text) returns true on success. On refusal it returns false, reason. The text must be valid UTF-8, cannot contain an embedded NUL, and is limited to 256 KiB.

Possible failure reasons include:

  • permission_denied:clipboard.write
  • clipboard_text_too_large
  • clipboard_text_contains_nul
  • clipboard_invalid_utf8
  • clipboard_busy
  • clipboard_clear_failed
  • clipboard_allocation_failed
  • clipboard_lock_failed
  • clipboard_write_failed
  • clipboard_unavailable_on_this_host

The API is synchronous and should be called in response to a deliberate player action. If another desktop application temporarily owns the clipboard, report clipboard_busy and let the player retry instead of looping every frame.

Built-in /pos and /rot commands

The official debug resource (open77_debug) registers these two authenticated commands; the clipboard permission that backs them is declared by open77_chat:

/pos
/rot

/pos copies the local player's current world position:

position = { x = 1660.068359, y = -723.649170, z = 50.512436 }

/rot copies the complete quaternion and the horizontal yaw:

orientation = { x = 0.000000, y = 0.000000, z = 0.707107, w = 0.707107 }, yaw = 90.000000

The command is registered on the server, then targets only the authenticated requesting client. The downloaded open77_chat client reads Open77.character.state(), performs the clipboard write, and returns a bounded result. The server never receives the previous clipboard contents. Success or failure is shown both in chat and through a middle-left WebUI notification.

This split is important for server packages: server network events are delivered to the active downloaded resource generation. A handler placed only in a protected bootstrap resource will not receive a normal server-resource event.

Copy a character transform from your own resource

The command implementation is only a convenience. A client resource can produce another format directly:

local state, stateError = Open77.character.state()
if not state or not state.attached then
    print(stateError or "player_transform_unavailable")
    return
end

local p = state.position
local q = state.orientation
local text = string.format(
    "vec4(%.3f, %.3f, %.3f, %.3f) at vec3(%.3f, %.3f, %.3f)",
    q.x, q.y, q.z, q.w, p.x, p.y, p.z
)

local copied, reason = Open77.clipboard.setText(text)
assert(copied, reason)

state.position, state.orientation, and state.yaw come from the same character snapshot, so the copied position and rotation describe one coherent sample.

// For agents & LLMsthis page as Markdownllms.txtllms-full.txt

// Guides Β· Lua API

Search the docs

1,905 guides and functions indexed

Try