Skip to content

SetPlayerInterfaceOptions

How a component is laid out for one player - the chat’s corner and lines, the scoreboard’s mode, and so on.

options is a table of key = value; numbers, booleans and texts are all written as text for the server, so lines = 12, show_stamina = false and anchor = "top-right" are what they look like. The value "default" (or an empty text) takes a key back to what everyone else has - the setting made for everyone, else the option’s own default - and a key that is not in the table is left as it is. A number may have a decimal point (it is kept to three places); a colour is a text of six hex digits, "F6E890" or "#F6E890" - never a number.

Sizes and margins are pixels on a screen 1080 pixels tall: on a taller or shorter screen the piece grows or shrinks with the height, and a wider screen only gives it more room across. anchor picks the corner or edge the piece is attached to and the margins count from the edges it touches; top and bottom are centred across, left and right centred down, center both, and a centred direction has no margin.

Component Key Value Default
chat anchor top-left, top, top-right, left, center, right, bottom-left, bottom, bottom-right bottom-left
chat margin_x 0 to 960 12
chat margin_y 0 to 540 64
chat width 300 to 1200 560
chat lines a whole number, 4 to 20 10
chat backing_alpha 0 to 100: the dark frame behind the lines while the box is closed 45
chat backing_alpha_open 0 to 100: the frame while the box is open or the chat is scrolled back 85
chat font_scale 0.6 to 1.6, times the usual size 1
scoreboard mode hold (shown while Tab is held), toggle (Tab opens it, Tab or Esc closes it) hold
scoreboard title text, at most 64 characters empty: KCD:MP - <server name>
party anchor top-left, left, bottom-left, top-right, right, bottom-right top-left
party margin_x 0 to 960 24
party margin_y 0 to 1000 173
party show_stamina true, false: the stamina bars of the members true
nameplates color six hex digits: the name’s colour when the mode gave the player none (SetPlayerColor) F6E890
nameplates font_scale 0.5 to 2 1
nameplates bar_width 40 to 240: the health bar 120
nameplates text name, id, name_id: what a plate says when the mode gave the player no label - their name, their player id, or Henry (3) name
nameplates peek_key the name of a keyboard key (lalt, lctrl, n, f4 …): the names show only while it is held; empty = they always show empty
nameplates peek_scope all, players: whose names wait for the peek_key - every plate’s, or the players’ alone (the NPC actors’ labels always show) all
nameplates npc_range a whole number, 0 to 255: the metres an NPC actor’s name shows up to (it fades over the last third); 0 = as far as the players’ names 0
compass span 30 to 180: the degrees of the horizon the compass strip covers 90
dialog side left, right: where a dialogue page’s choices (ShowPlayerDialogue) stand - the right is where the game’s own conversations put them left
dialog bars off, dialog (while a dialogue page is open), on (from now until set back): the game’s own black cinema bars, with the subtitles moved into the lower one off
hud compass, stats, subtitles, hints, cursor, buffs, info_text, game_log, common_event, fancy_event, tutorial_message 1 shows the game’s own HUD piece of that name, 0 hides it (true, false, on, off, yes and no are read as the same); SetPlayerHudVisible says what each piece is 1

The other components have no options. The call is all or nothing: one bad key or value and nothing changes. The second value says what was wrong, in words - "unknown component 'x'", "unknown option 'x' for the chat", "lines must be a whole number from 4 to 20", "width must be a number from 300 to 1200", "anchor must be one of top-left, top, ...", "show_stamina must be true or false", "color must be a colour of six hex digits, like F6E890", "title must be at most 64 characters", "peek_key must be the name of a keyboard key: ...", or "not connected". The scoreboard’s title replaces the KCD:MP - <server name> part of its title line; the number of players and the page stay after it.

The name plates’ text and peek_key are for a server whose players do not know each other: with peek_key = "lalt" the names show only while Left Alt is held (the health bars, a chat bubble and a vendor’s prompt follow their own rules), and text = "id" makes a plate say the player’s id until the mode gives that player a label - or, for one player’s screen alone, a name they were told (SetPlayerNameplateFor). peek_scope = "players" keeps the key for the players’ names: the labels of the mode’s NPC actors - a shopkeeper, a guard, a quest giver (SetActorNameplate) - stay readable. The key is watched, never taken from the game; when it is also the cursor key (Left Alt unless the player chose another), holding it does not bring the pointer up.

SetPlayerInterfaceOptions(pid, component, options)
Parameter Type
pid number the player
component string "chat", "scoreboard", "party", "nameplates", "hud" or "compass"
options table { key = value } - numbers, booleans and texts; "default" takes a key back to its default

true, or false, reason - the reason as a person reads it ("lines must be a whole number from 4 to 20" …)

-- a spectator's screen: the chat small in the top-right corner, the party frames out of the way
function setSpectatorView(pid)
local ok, why = SetPlayerInterfaceOptions(pid, "chat", { anchor = "top-right", margin_x = 16, margin_y = 24, lines = 6, width = 420 })
if not ok then Log("chat layout refused: " .. why) end
SetPlayerInterfaceOptions(pid, "party", { anchor = "bottom-left", show_stamina = false })
end
-- and back to what everyone else has
function endSpectatorView(pid)
SetPlayerInterfaceOptions(pid, "chat", { anchor = "default", margin_x = "default", margin_y = "default", lines = "default", width = "default" })
SetPlayerInterfaceOptions(pid, "party", { anchor = "default", show_stamina = "default" })
end

SetInterfaceOptionsForAll · SetPlayerInterface · GetPlayerInterface · the Interface group of the index