Skip to content

Game plugins ​

A game plugin is a plugin that people play together at a table. Dissent runs the lobby for you. Your plugin only has to be the game.

Each server has a games room. The server admin installs games there. A member picks a game, opens a table, friends sit down, the host presses Start, and your plugin opens.

You do not ask for any permission. A game sees only what everyone already sees in the games room.

What you get from Dissent ​

  • A lobby: host, seats, watchers, and settings the host can choose.
  • A fair way to start a round: everyone gets the same seed.
  • A way to send small messages between players.
  • A result for each round, and leaderboards.
  • Sound that follows the app's volume.

The manifest ​

Add "games" to context and add a game block. Both go together. One without the other is refused.

json
{
  "id": "dice-duel",
  "name": "Dice Duel",
  "version": "1.0.0",
  "description": "Roll higher than your friend.",
  "author": "You",
  "tier": 2,
  "context": ["games"],
  "url": "https://example.com/dice-duel/plugin.html",
  "declared_permissions": [],
  "allowed_fetch_domains": [],
  "categories": ["gaming"],
  "sdk_version": "1",
  "game": {
    "api": 1,
    "placement": "over_chat",
    "players": [2, 4],
    "watchers": true,
    "drop_in": false,
    "rounds": true,
    "blurb": "Roll higher than your friend.",
    "settings": [
      {
        "key": "dice",
        "label": "Dice",
        "default": 1,
        "options": [
          { "value": 1, "label": "One die" },
          { "value": 2, "label": "Two dice" }
        ]
      }
    ],
    "leaderboard": { "split_by": ["dice"] }
  }
}

The game block ​

FieldWhat it does
apiAlways 1.
placementWhere the game opens. See below.
players[min, max]. Two numbers. At least 1, at most 16.
watcherstrue lets people watch without a seat. Default true.
drop_intrue lets people sit down after Start. Default false.
roundstrue gives you Play again, a result, and leaderboards.
blurbOne line for the games room. 120 characters at most.
coverOptional. A relative path to a .webp, .png, .jpg or .avif inside your plugin. No SVG.
settingsChoices the host picks before Start. Up to 4.
leaderboard.split_byWhich settings give each mix its own board. Up to 2.

Placement ​

ValueThe game opens…
over_chatOver the chat panel, with no bar from Dissent. You draw your own menu and call Dissent.game.leave() to leave.
chatIn a strip over the top of the chat.
panelIn a panel over the main area.
fullscreenOver all of Dissent. Changing to this later needs the admin to add the plugin again.

Settings ​

Each setting is a key, a label, a default and a list of options. Each option has a value and a label (and an optional hint). The room draws the pickers. The node only accepts values you listed. If a value is missing, the default is used.

To hide a setting when another one has a certain value, add "hide_when": { "key": "mode", "is": ["last"] }. A hidden setting does not split a leaderboard.

The lobby ​

Dissent runs it. In plain words:

  • Any member can open a table, sit, or watch. One seat per member per server.
  • The host presses Start once enough players have sat down.
  • After Start, only a game with drop_in takes new players.
  • If the host leaves, the player who sat down first becomes host. When the last player leaves, the table closes.
  • A table that sits idle is closed after a while.

A minimal game ​

Load the SDK and ask for the table.

html
<script src="https://app.dissent.chat/sdk/v1/dissent-plugin-sdk.iife.js"></script>
<script>
  async function main() {
    await Dissent.init();
    let lobby = await Dissent.game.lobby();

    Dissent.game.onLobby(async () => {
      lobby = await Dissent.game.lobby();
      // a new round? lobby.round went up and lobby.seed is new.
    });

    Dissent.game.onMessage((from, data) => {
      // another player's message. Never your own.
    });
  }
  main();
</script>

Rounds and the seed ​

Every Start gives the table a fresh seed (a number) and adds one to round. All players build the same world from the same seed. That is how a dice roll or a maze comes out the same for everyone.

Dissent.game.lobby() returns, among other things: seed, round, started_at, elapsed_ms, result, settings, members, host_id, and you (your seat, or null).

When a round ends the table goes back to open. The host presses Start to play again, or your plugin calls Dissent.game.start().

Time a round with elapsed_ms ​

elapsed_ms is how long ago the round started, by the node's clock. Add your own time since the answer arrived.

js
const lobby = await Dissent.game.lobby();
const got = performance.now();
const roundMs = () => lobby.elapsed_ms + (performance.now() - got);

Never use started_at for timing

Do not compare Date.now() to started_at. Players' clocks differ by seconds. A PC with a fast clock started a countdown early and skipped the 3 · 2 · 1. Use elapsed_ms.

Talking to the other players ​

Dissent.game.send(data) sends to everyone else at the table. onMessage receives it.

  • At most 1 KB of JSON per message and 20 messages a second.
  • Watchers cannot send.
  • You never get your own messages.
  • A missed message is not sent again, so send the whole state, not just the change.
  • Only works while the table is playing.

Reporting a result ​

When a round ends, every player's copy of your game reports the result once.

js
await Dissent.game.report({
  round: lobby.round,
  places: [
    { user_id: "alice-id", place: 1, score: 12, label: "12 points" },
    { user_id: "bob-id",   place: 2, score: 9,  label: "9 points" },
  ],
});
  • List every player who is seated, ranked. Ties share a place: 1, 1, 3.
  • score is optional. Higher is better. Report a time as a negative number.
  • label is optional. It is how people see the score. 32 characters at most.
  • You can report only once per round. The first report counts.
  • Only a game with rounds: true can report.

The reports must agree ​

The node settles the round when everyone has reported, or 30 seconds after the first report.

  • Two players: both reports must agree on who came where.
  • Three or more: a strict majority must agree.
  • One report from a shared round: the result is "disputed".
  • One player in the round: their report stands.

If the reports disagree there is no result and no leaderboard entry. So rank from what every player shared (each player sends their own finish with send), not from what your copy saw by its own timing. Two copies that each trust their own timing will disagree on a close finish.

Each player's shown score is the lowest score any agreeing report gave them. One report can't inflate a best.

When the round settles, the table comes back open. onLobby fires, and lobby.result holds { round, places, disputed, prize }.

Leaderboards ​

A game with rounds gets leaderboards for free. The node counts settled rounds that nobody disputed: rounds played, wins, podiums, and a best score.

js
const board = await Dissent.game.leaderboard({ period: "week" });
// board.wins and board.best: the top 10, plus your own row.
  • period is "all" or "week" (the week starts Monday, UTC).
  • With no board, you get the board for your table's settings.
  • split_by gives each mix of settings its own board.
  • It fails with leaderboards_off when the server admin turned boards off.

Who can switch boards off:

  • Each member can hide themselves in Privacy ("Show me on game leaderboards"). They are left off for everyone else.
  • The server admin (Server Settings → Plugins) can turn all boards off, and can reset one game's boards. What was already counted stays when boards are switched off.

Sound ​

Follow the app's volume and the user's deafen. Never play sound at full volume.

js
let sound = await Dissent.game.sound();           // { volume: 0..1, deafened }
Dissent.game.onSound((s) => { sound = s; });
// when you play: if (sound.deafened) skip it, else use gain = sound.volume

Game frames may play audio without a click. Your game should sound like itself, not like Dissent's own sounds.

Older apps ​

Rounds, reporting, leave, sound and leaderboard are newer. An older app answers them with an error. Catch it and carry on. A round still settles from the other players' reports.

Reference ​

The full list of Dissent.game.* methods is in the SDK API.