Skip to content

KcdMp.itemIcon

The address of an item’s picture, for an <img> or a CSS background.

key is the item class’s GUID or its game name ("longSwordDuel", in any case) - the class and the name a game mode’s GetItemInfo gives; the numeric id is the server’s own and does not work here. The picture is the game’s inventory icon, 64 by 64 pixels on a transparent background; size it with CSS. An item without a picture, or a key the game does not know, fails to load like any missing image: the <img>’s error event fires.

The address is the same in every player’s game, so a stylesheet may use it too (https://ui.kcd-mp.invalid/icons/items/<key>.png). In a browser, in mock mode, every valid key gives a plain placeholder square. A key of another shape gives "".

KcdMp.itemIcon(key)
Parameter Type
key string the item class’s GUID or game name

string - the picture’s address, or "" when key is neither a GUID nor a name

const img = document.createElement("img");
img.src = KcdMp.itemIcon("longSwordDuel");
img.alt = "Duelling longsword";
img.width = 48;
img.addEventListener("error", () => img.remove()); // no picture for this item
document.getElementById("slot").append(img);

KcdMp.env.mock · the The game’s pictures and typefaces group of the index