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.
Syntax
Section titled “Syntax”KcdMp.onSurfaceUse(fn)| Parameter | Type | |
|---|---|---|
fn |
() => void |
called at each use |
Returns
Section titled “Returns”() => void - a function that takes the handler off again
Example
Section titled “Example”let page = 0;KcdMp.onSurfaceUse(() => { page = (page + 1) % pages.length; show(page); KcdMp.emitServer("book.page", page).catch(() => {});});See also
Section titled “See also”KcdMp.surface · KcdMp.emitServer · KcdMp.mock.use · the Pages on surfaces in the world group of the index
