Skip to content

KcdMp.onSurfaceUse

Registers a function for the player’s use key on this surface.

A surface the game mode gave a use prompt (CreateWebSurface’s prompt option, or SetEntityPrompt) shows it in the game’s own use hint when a player looks at the surface from close by; their use key then calls fn() - on that player’s copy of the page alone - and the mode’s OnPlayerUseWebSurface. A page uses it for what only that player should see (the next page of a book, the next notice), and tells the mode what it needs to know with KcdMp.emitServer.

KcdMp.onSurfaceUse(fn)
Parameter Type
fn () => void called at each use

() => void - a function that takes the handler off again

let page = 0;
KcdMp.onSurfaceUse(() => {
page = (page + 1) % pages.length;
show(page);
KcdMp.emitServer("book.page", page).catch(() => {});
});

KcdMp.surface · KcdMp.emitServer · KcdMp.mock.use · the Pages on surfaces in the world group of the index