Files
factorio-expcluster/exp_scenario/index.ts
T
bbassieandClaude Opus 5.5 54941b85aa Sync the toolbar of players through the controller
The toolbar order, favourites, and open panels were saved into
exp_legacy's PlayerData, which was never synced, and the file doing so
was no longer loaded. When a player leaves, the lua side now sends
Gui.toolbar.get_state as json compressed with helpers.encode_string,
and the controller stores the string on the player record.

When the player joins again the instance plugin sends the stored string
over rcon to exp_scenario.player_settings.receive_toolbar, which
decodes it and calls Gui.toolbar.set_state. exp_gui builds the toolbar
in on_player_joined_game, so it exists by the time the rcon arrives.
A string which does not decode, or a state naming buttons which no
longer exist, is logged and ignored rather than raising in the game.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-14 22:10:31 +00:00

68 lines
2.0 KiB
TypeScript

import * as lib from "@clusterio/lib";
import * as messages from "./messages.js";
import { permissions as scenarioPermissions, type ScenarioPermissionName } from "./permissions.js";
declare module "@clusterio/lib" {
// Everything checked in game through exp_roles, plus the permissions checked on the controller
export interface Permissions extends Record<ScenarioPermissionName, never> {
"exp_scenario.config.view": never;
"exp_scenario.config.edit": never;
"exp_scenario.seed": never;
"exp_scenario.join_message.set": never;
"exp_scenario.join_message.set_other": never;
}
}
export const plugin: lib.PluginDeclaration = {
name: "exp_scenario",
title: "ExpGaming - Scenario",
description: "Clusterio plugin implementing the Explosive Gaming scenario.",
controllerEntrypoint: "./dist/node/controller.js",
instanceEntrypoint: "./dist/node/instance.js",
messages: [
messages.SeedRequest,
messages.FeatureUpdatedEvent,
messages.FeatureListRequest,
messages.FeatureUpdateRequest,
messages.PlayerGetRequest,
messages.JoinMessageSetRequest,
messages.PlayerLocaleEvent,
messages.PlayerToolbarEvent,
],
permissions: [
...scenarioPermissions,
{
name: "exp_scenario.config.view",
title: "View ExpScenario Config",
description: "View the config for all submodules of ExpScenario",
},
{
name: "exp_scenario.config.edit",
title: "Edit ExpScenario Config",
description: "Edit the config for all submodules of ExpScenario",
},
{
name: "exp_scenario.seed",
title: "Seed ExpScenario roles and groups",
description: "Create the roles and permission groups the scenario shipped with",
},
{
name: "exp_scenario.join_message.set",
title: "Set own join message",
description: "Set the message shown to everyone when you join, in game this is /set-join-message",
},
{
name: "exp_scenario.join_message.set_other",
title: "Set join messages of others",
description: "Set the message shown to everyone when another user joins",
},
],
webEntrypoint: "./web",
routes: [
"/scenario_features",
],
};