From 3f68594a117273f1ae9b0d1636413595a4ef8333 Mon Sep 17 00:00:00 2001 From: Mees van der Wijk Date: Sun, 10 Aug 2025 16:26:56 +0200 Subject: [PATCH] Added game events --- ModuleClientAPIGameLibController.md | 2 +- ModuleServerAPIGameLibGame.md | 70 +++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+), 1 deletion(-) diff --git a/ModuleClientAPIGameLibController.md b/ModuleClientAPIGameLibController.md index 99208a5..f2a4889 100644 --- a/ModuleClientAPIGameLibController.md +++ b/ModuleClientAPIGameLibController.md @@ -15,7 +15,7 @@ Controller.call(action, mode, intensity?); | Argument | Type | Description | | -------------------- | ----------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------- | | action | "left" / "right" / "up" / "down" / "upleft" / "upright" / "downleft" / "downright" / "start" / "select" / "back" / "identify" | The action to send. | -| mode | "on" / "off" | The ID of the controller. | +| mode | "on" / "off" | The mode of the action. | | (Optional) intensity | number | The intensity of the button press (between 0 and 1). | ### callCustom diff --git a/ModuleServerAPIGameLibGame.md b/ModuleServerAPIGameLibGame.md index aa84b69..165880e 100644 --- a/ModuleServerAPIGameLibGame.md +++ b/ModuleServerAPIGameLibGame.md @@ -112,3 +112,73 @@ Game.getPlayers(); **Return** [GamePlayer](./ModuleServerAPIGameLibGamePlayer)[] _GamePlayer instances._ ## Events + +### on: playerJoinGame + +Triggers when a player joins the game. + +```javascript +Game.on('playerJoinGame', (player) => {}); +``` + +| Argument | Type | Description | +| -------- | ------------------------------------------------ | -------------------------------- | +| player | [GamePlayer](./ModuleServerAPIGameLibGamePlayer) | The player that joined the game. | + +### on: playerLeaveGame + +Triggers when a player leaves the game. + +```javascript +Game.on('playerLeaveGame', (player) => {}); +``` + +| Argument | Type | Description | +| -------- | ------------------------------------------------ | -------------------------------- | +| player | [GamePlayer](./ModuleServerAPIGameLibGamePlayer) | The player that leaved the game. | + +### on: gameStart + +Triggers when the game starts. + +```javascript +Game.on('gameStart', () => {}); +``` + +### on: gameStop + +Triggers when the game stops. + +```javascript +Game.on('gameStop', () => {}); +``` + +### on: action + +Receive actions from a players controller. + +```javascript +Game.on('action', (player, action, mode, intensity?) => {}); +``` + +| Argument | Type | Description | +| -------------------- | ----------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------- | +| player | [GamePlayer](./ModuleServerAPIGameLibGamePlayer) | The player that leaved the game. | +| action | "left" / "right" / "up" / "down" / "upleft" / "upright" / "downleft" / "downright" / "start" / "select" / "back" / "identify" | The received action. | +| mode | "on" / "off" | The mode of the action. | +| (Optional) intensity | number | \*_Only when control is analog._ The intensity of the action. | + +### on: customAction + +Receive custom from for a players controller. + +```javascript +Game.on('customAction', (player, action, mode, intensity?) => {}); +``` + +| Argument | Type | Description | +| -------------------- | ------------------------------------------------ | ------------------------------------------------------------- | +| player | [GamePlayer](./ModuleServerAPIGameLibGamePlayer) | The player that leaved the game. | +| action | string | The received action. | +| mode | "on" / "off" | The mode of the action. | +| (Optional) intensity | number | \*_Only when control is analog._ The intensity of the action. |