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
compass span 30 to 180: the degrees of the horizon the compass strip covers 90
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", 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.

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