mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2026-11-20 15:33:12 +09:00
Merge branch 'main' into feature/reports-plugin
This commit is contained in:
103 files changed
+4492
-4129
No files matched your search
@@ -1,6 +1,157 @@
|
||||
import * as lib from "@clusterio/lib";
|
||||
import { BaseControllerPlugin } from "@clusterio/controller";
|
||||
import { RoleMetaRecord } from "@expcluster/roles";
|
||||
import { GroupRecord, GroupPermissions, RoleMappingRecord } from "@expcluster/permission-groups";
|
||||
import { ControllerPlugin as RolesPlugin } from "@expcluster/roles/dist/node/controller.js";
|
||||
import { ControllerPlugin as GroupsPlugin } from "@expcluster/permission-groups/dist/node/controller.js";
|
||||
import * as messages from "./messages.js";
|
||||
import { SeedRole, SeedGroup, seedRoles, seedGroups, flattenSeedPermissions } from "./seed.js";
|
||||
|
||||
export class ControllerPlugin extends BaseControllerPlugin {
|
||||
async init() {
|
||||
this.controller.handle(messages.SeedRequest, this.handleSeedRequest.bind(this));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the roles and permission groups the scenario shipped with.
|
||||
*
|
||||
* Roles which already exist by name are reused and only gain the seed
|
||||
* permissions, groups which already exist by name are reset to the seed.
|
||||
*/
|
||||
async handleSeedRequest() {
|
||||
const rolesPlugin = RolesPlugin.get(this.controller);
|
||||
const groupsPlugin = GroupsPlugin.get(this.controller);
|
||||
if (!rolesPlugin || !groupsPlugin) {
|
||||
throw new lib.RequestError("Seeding requires the exp_roles and exp_groups plugins");
|
||||
}
|
||||
|
||||
const roleIds = new Map<string, number>();
|
||||
for (const [index, seedRole] of seedRoles.entries()) {
|
||||
const role = this.seedRole(seedRole);
|
||||
if (!role) {
|
||||
continue;
|
||||
}
|
||||
|
||||
roleIds.set(seedRole.name, role.id);
|
||||
rolesPlugin.roleMeta.set(new RoleMetaRecord(
|
||||
role.id,
|
||||
index + 1,
|
||||
seedRole.priority ?? 0,
|
||||
seedRole.shortHand,
|
||||
"",
|
||||
seedRole.color,
|
||||
seedRole.autoAssignHours === undefined ? null : seedRole.autoAssignHours * 3600000,
|
||||
seedRole.blockAutoAssign ?? false,
|
||||
));
|
||||
}
|
||||
|
||||
const groupIds = new Map<string, number>();
|
||||
for (const seedGroup of seedGroups) {
|
||||
groupIds.set(seedGroup.name, this.seedGroup(groupsPlugin, seedGroup).id);
|
||||
}
|
||||
|
||||
this.seedRoleMappings(groupsPlugin, roleIds, groupIds);
|
||||
this.logger.info(`Seeded ${roleIds.size} roles and ${groupIds.size} permission groups`);
|
||||
}
|
||||
|
||||
/** Find or create the clusterio role for a seed role, returns undefined if it has no role to use. */
|
||||
seedRole(seedRole: SeedRole) {
|
||||
const roles = this.controller.roles;
|
||||
if (seedRole.isAdmin) {
|
||||
return roles.get(lib.Role.DefaultAdminRoleId);
|
||||
}
|
||||
if (seedRole.isDefault) {
|
||||
const defaultRoleId = this.controller.config.get("controller.default_role_id");
|
||||
return defaultRoleId !== null ? roles.get(defaultRoleId) : undefined;
|
||||
}
|
||||
|
||||
const permissions = flattenSeedPermissions(seedRole);
|
||||
for (const permission of permissions) {
|
||||
if (!lib.permissions.has(permission)) {
|
||||
this.logger.warn(`Seed role ${seedRole.name} grants unknown permission ${permission}`);
|
||||
}
|
||||
}
|
||||
|
||||
let role = [...roles.valuesMutable()].find(other => other.name === seedRole.name);
|
||||
if (role) {
|
||||
for (const permission of permissions) {
|
||||
role.permissions.add(permission);
|
||||
}
|
||||
} else {
|
||||
const id = Math.max(5, ...[...roles.keys()].map(other => other + 1));
|
||||
role = new lib.Role(id, seedRole.name, "", permissions);
|
||||
this.logger.info(`Created role ${seedRole.name}`);
|
||||
}
|
||||
roles.set(role);
|
||||
return role;
|
||||
}
|
||||
|
||||
/** Find or create the permission group for a seed group. */
|
||||
seedGroup(groupsPlugin: GroupsPlugin, seedGroup: SeedGroup) {
|
||||
const permissions = new GroupPermissions(seedGroup.isBlacklist, [...seedGroup.inputActions]);
|
||||
const existing = [...groupsPlugin.groups.values()].find(other => other.name === seedGroup.name);
|
||||
const group = new GroupRecord(existing?.id ?? newId(groupsPlugin.groups), seedGroup.name, permissions);
|
||||
if (!existing) {
|
||||
this.logger.info(`Created permission group ${seedGroup.name}`);
|
||||
}
|
||||
groupsPlugin.groups.set(group);
|
||||
return group;
|
||||
}
|
||||
|
||||
/**
|
||||
* Map each seed role onto its seed group.
|
||||
*
|
||||
* The mapping with the highest priority decides a player's group, so the
|
||||
* priorities follow how exp_roles picks a player's highest role: role
|
||||
* priority first, then the role order.
|
||||
*/
|
||||
seedRoleMappings(groupsPlugin: GroupsPlugin, roleIds: Map<string, number>, groupIds: Map<string, number>) {
|
||||
// Lowest role first, so the mapping priority rises with the role
|
||||
const ranked = seedRoles
|
||||
.filter(seedRole => seedRole.group !== undefined && roleIds.has(seedRole.name))
|
||||
.reverse()
|
||||
.sort((a, b) => (a.priority ?? 0) - (b.priority ?? 0));
|
||||
const seededRoleIds = new Set(ranked.map(seedRole => roleIds.get(seedRole.name)!));
|
||||
|
||||
// A mapping of a single seed role is reused, every other mapping keeps its priority
|
||||
const existing = new Map<number, RoleMappingRecord>();
|
||||
const taken = new Set<number>();
|
||||
for (const mapping of groupsPlugin.roleMappings.values()) {
|
||||
const [roleId] = mapping.roleIds;
|
||||
if (mapping.roleIds.size === 1 && seededRoleIds.has(roleId)) {
|
||||
existing.set(roleId, mapping);
|
||||
} else {
|
||||
taken.add(mapping.priority);
|
||||
}
|
||||
}
|
||||
|
||||
const mappings = [];
|
||||
let priority = 0;
|
||||
for (const seedRole of ranked) {
|
||||
priority += 1;
|
||||
while (taken.has(priority)) {
|
||||
priority += 1;
|
||||
}
|
||||
|
||||
const roleId = roleIds.get(seedRole.name)!;
|
||||
mappings.push(new RoleMappingRecord(
|
||||
existing.get(roleId)?.id ?? newId(groupsPlugin.roleMappings),
|
||||
new Set([roleId]),
|
||||
groupIds.get(seedRole.group!)!,
|
||||
priority,
|
||||
true,
|
||||
));
|
||||
}
|
||||
|
||||
groupsPlugin.roleMappings.setMany(mappings);
|
||||
return mappings;
|
||||
}
|
||||
}
|
||||
|
||||
function newId(datastore: { has(id: number): boolean }) {
|
||||
let id = Math.random() * 2 ** 31 | 0;
|
||||
while (datastore.has(id)) {
|
||||
id = Math.random() * 2 ** 31 | 0;
|
||||
}
|
||||
return id;
|
||||
}
|
||||
+30
-24
@@ -1,39 +1,45 @@
|
||||
import * as lib from "@clusterio/lib";
|
||||
// import * as Messages from "./messages";
|
||||
|
||||
// Defines a permission for every in game action and role flag used by the scenario
|
||||
import "./permissions";
|
||||
|
||||
lib.definePermission({
|
||||
name: "exp_scenario.config.view",
|
||||
title: "View ExpScenario Config",
|
||||
description: "View the config for all submodules of ExpScenario",
|
||||
});
|
||||
|
||||
lib.definePermission({
|
||||
name: "exp_scenario.config.edit",
|
||||
title: "Edit ExpScenario Config",
|
||||
description: "Edit the config for all submodules of ExpScenario",
|
||||
});
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
export const plugin: lib.PluginDeclaration = {
|
||||
name: "exp_scenario",
|
||||
title: "exp_scenario",
|
||||
description: "Example Description. Plugin. Change me in index.ts",
|
||||
controllerEntrypoint: "./dist/node/controller",
|
||||
instanceEntrypoint: "./dist/node/instance",
|
||||
controllerEntrypoint: "./dist/node/controller.js",
|
||||
instanceEntrypoint: "./dist/node/instance.js",
|
||||
|
||||
/*
|
||||
messages: [
|
||||
messages.SeedRequest,
|
||||
],
|
||||
|
||||
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",
|
||||
},
|
||||
],
|
||||
|
||||
webEntrypoint: "./web",
|
||||
routes: [
|
||||
"/exp_scenario",
|
||||
],
|
||||
*/
|
||||
};
|
||||
@@ -1,95 +1,11 @@
|
||||
import { plainJson, jsonArray, JsonBoolean, JsonNumber, JsonString, StringEnum } from "@clusterio/lib";
|
||||
import { Type, Static } from "@sinclair/typebox";
|
||||
|
||||
export class PluginExampleEvent {
|
||||
declare ["constructor"]: typeof PluginExampleEvent;
|
||||
static type = "event" as const;
|
||||
static src = ["host", "control"] as const;
|
||||
static dst = ["controller", "host", "instance"] as const;
|
||||
/** Create the roles and permission groups the scenario shipped with, see seed.ts. */
|
||||
export class SeedRequest {
|
||||
declare ["constructor"]: typeof SeedRequest;
|
||||
static plugin = "exp_scenario" as const;
|
||||
static permission = "exp_scenario.example.permission.event";
|
||||
|
||||
constructor(
|
||||
public myString: string,
|
||||
public myNumberArray: number[],
|
||||
) {
|
||||
}
|
||||
|
||||
static jsonSchema = Type.Object({
|
||||
"myString": Type.String(),
|
||||
"myNumberArray": Type.Array(Type.Number()),
|
||||
});
|
||||
|
||||
static fromJSON(json: Static<typeof PluginExampleEvent.jsonSchema>) {
|
||||
return new PluginExampleEvent(json.myString, json.myNumberArray);
|
||||
}
|
||||
}
|
||||
|
||||
export class PluginExampleRequest {
|
||||
declare ["constructor"]: typeof PluginExampleRequest;
|
||||
static type = "request" as const;
|
||||
static src = ["host", "control"] as const;
|
||||
static dst = ["controller", "host", "instance"] as const;
|
||||
static plugin = "exp_scenario" as const;
|
||||
static permission = "exp_scenario.example.permission.request";
|
||||
static src = "control" as const;
|
||||
static dst = "controller" as const;
|
||||
static permission = "exp_scenario.seed" as const;
|
||||
|
||||
constructor(
|
||||
public myString: string,
|
||||
public myNumberArray: number[],
|
||||
) {
|
||||
}
|
||||
|
||||
static jsonSchema = Type.Object({
|
||||
"myString": Type.String(),
|
||||
"myNumberArray": Type.Array(Type.Number()),
|
||||
});
|
||||
|
||||
static fromJSON(json: Static<typeof PluginExampleRequest.jsonSchema>) {
|
||||
return new PluginExampleRequest(json.myString, json.myNumberArray);
|
||||
}
|
||||
|
||||
static Response = plainJson(Type.Object({
|
||||
"myResponseString": Type.String(),
|
||||
"myResponseNumbers": Type.Array(Type.Number()),
|
||||
}));
|
||||
}
|
||||
|
||||
export class ExampleSubscribableValue {
|
||||
constructor(
|
||||
public id: string,
|
||||
public updatedAtMs: number,
|
||||
public isDeleted: boolean,
|
||||
) {
|
||||
}
|
||||
|
||||
static jsonSchema = Type.Object({
|
||||
id: Type.String(),
|
||||
updatedAtMs: Type.Number(),
|
||||
isDeleted: Type.Boolean(),
|
||||
});
|
||||
|
||||
static fromJSON(json: Static<typeof this.jsonSchema>) {
|
||||
return new this(json.id, json.updatedAtMs, json.isDeleted);
|
||||
}
|
||||
}
|
||||
|
||||
export class ExampleSubscribableUpdate {
|
||||
declare ["constructor"]: typeof ExampleSubscribableUpdate;
|
||||
static type = "event" as const;
|
||||
static src = "controller" as const;
|
||||
static dst = "control" as const;
|
||||
static plugin = "exp_scenario" as const;
|
||||
static permission = "exp_scenario.example.permission.subscribe";
|
||||
|
||||
constructor(
|
||||
public updates: ExampleSubscribableValue[],
|
||||
) { }
|
||||
|
||||
static jsonSchema = Type.Object({
|
||||
"updates": Type.Array(ExampleSubscribableValue.jsonSchema),
|
||||
});
|
||||
|
||||
static fromJSON(json: Static<typeof this.jsonSchema>) {
|
||||
return new this(json.updates.map(update => ExampleSubscribableValue.fromJSON(update)));
|
||||
}
|
||||
constructor() {}
|
||||
}
|
||||
@@ -7,7 +7,6 @@ local add_static, add_dynamic = Commands.add_rcon_static, Commands.add_rcon_dyna
|
||||
|
||||
add_static("Gui", require("modules/exp_gui"))
|
||||
|
||||
add_static("Group", require("modules.exp_legacy.expcore.permission_groups"))
|
||||
add_static("Roles", require("modules/exp_roles"))
|
||||
add_static("Datastore", require("modules.exp_legacy.expcore.datastore"))
|
||||
add_static("External", require("modules.exp_legacy.expcore.external"))
|
||||
@@ -3,7 +3,7 @@ Adds a virtual layer to store power to save space.
|
||||
]]
|
||||
|
||||
local Commands = require("modules/exp_commands")
|
||||
local vlayer = require("modules.exp_legacy.modules.control.vlayer")
|
||||
local Vlayer = require("modules/exp_scenario/control/vlayer")
|
||||
|
||||
--- @class ExpCommand_vlayer.commands
|
||||
local commands = {}
|
||||
@@ -14,7 +14,7 @@ commands.vlayer = Commands.new("vlayer-info", { "exp-commands_vlayer.description
|
||||
:register(function(player)
|
||||
local index = 3
|
||||
local response = { "", "exp-commands_vlayer.title" } --- @type LocalisedString
|
||||
for title, value in pairs(vlayer.get_circuits()) do
|
||||
for title, value in pairs(Vlayer.get_circuits()) do
|
||||
response[index] = { "exp-commands_vlayer.result", title, value }
|
||||
index = index + 1
|
||||
end
|
||||
|
||||
@@ -67,6 +67,7 @@ add(require("modules/exp_scenario/control/roles"))
|
||||
add(require("modules/exp_scenario/control/spawn_area"))
|
||||
add(require("modules/exp_scenario/control/spectate"))
|
||||
add(require("modules/exp_scenario/control/station_auto_name"))
|
||||
add(require("modules/exp_scenario/control/vlayer"))
|
||||
|
||||
--- Guis
|
||||
add(require("modules/exp_scenario/gui/autofill"))
|
||||
@@ -83,5 +84,7 @@ add(require("modules/exp_scenario/gui/rocket_info"))
|
||||
add(require("modules/exp_scenario/gui/science_production"))
|
||||
add(require("modules/exp_scenario/gui/surveillance"))
|
||||
add(require("modules/exp_scenario/gui/task_list"))
|
||||
add(require("modules/exp_scenario/gui/vlayer"))
|
||||
add(require("modules/exp_scenario/gui/warp_list"))
|
||||
add(require("modules/exp_scenario/gui/debug/shim"))
|
||||
add(require("modules/exp_scenario/gui/debug/event_view"))
|
||||
@@ -9,9 +9,6 @@ Roles.define_permission_trigger("exp_scenario.player.admin", function(player, st
|
||||
player.admin = state
|
||||
end)
|
||||
|
||||
Roles.define_permission_trigger("exp_scenario.player.spectator", function(player, state)
|
||||
player.spectator = state
|
||||
end)
|
||||
|
||||
return {
|
||||
events = {
|
||||
|
||||
@@ -0,0 +1,673 @@
|
||||
--[[-- Control - Virtual Layer
|
||||
Stores solar panels, accumulators and landfill in a virtual layer which produces power through interface entities
|
||||
]]
|
||||
|
||||
local ExpUtil = require("modules/exp_util")
|
||||
local Storage = require("modules/exp_util/storage")
|
||||
local config = require("modules.exp_legacy.config.vlayer")
|
||||
|
||||
local floor = math.floor
|
||||
local min = math.min
|
||||
local max = math.max
|
||||
local mega = 1000000
|
||||
|
||||
--- @alias ExpScenario_Vlayer.InterfaceType "energy" | "circuit" | "storage_input" | "storage_output"
|
||||
|
||||
--- @class ExpScenario_Vlayer.Interfaces
|
||||
--- @field energy LuaEntity[]
|
||||
--- @field circuit LuaEntity[]
|
||||
--- @field storage_input LuaEntity[]
|
||||
--- @field storage_output LuaEntity[]
|
||||
|
||||
--- @class ExpScenario_Vlayer.Properties
|
||||
--- @field total_surface_area number Tiles provided by landfill
|
||||
--- @field used_surface_area number Tiles taken by allocated items
|
||||
--- @field total_production number MW of every solar panel stored, allocated or not
|
||||
--- @field production number MW of the allocated solar panels
|
||||
--- @field discharge number MW the allocated accumulators can discharge
|
||||
--- @field capacity number MJ the allocated accumulators can hold
|
||||
|
||||
--- @class ExpScenario_Vlayer.PowerItem
|
||||
--- @field value number J released by burning one
|
||||
--- @field count number
|
||||
|
||||
--- @class ExpScenario_Vlayer.Storage
|
||||
--- @field items table<string, number> Every stored item, allocated or not
|
||||
--- @field unallocated table<string, number> Items waiting for surface area
|
||||
--- @field power_items table<string, ExpScenario_Vlayer.PowerItem> Fuel burned when the stored energy is low
|
||||
--- @field energy number J
|
||||
|
||||
--- @class ExpScenario_Vlayer.Statistics
|
||||
--- @field total_surface_area number
|
||||
--- @field used_surface_area number
|
||||
--- @field remaining_surface_area number Surface area left after the unallocated items are counted
|
||||
--- @field surface_area number
|
||||
--- @field production_multiplier number
|
||||
--- @field energy_max number W when the sun is up
|
||||
--- @field energy_production number W right now
|
||||
--- @field energy_total_production number W sustained if every stored solar panel was allocated
|
||||
--- @field energy_sustained number W averaged over a day
|
||||
--- @field energy_capacity number J
|
||||
--- @field energy_storage number J
|
||||
|
||||
--- @class ExpScenario_Vlayer.Data
|
||||
--- @field interfaces ExpScenario_Vlayer.Interfaces
|
||||
--- @field properties ExpScenario_Vlayer.Properties
|
||||
--- @field storage ExpScenario_Vlayer.Storage
|
||||
--- @field surface LuaSurface | table The surface the day cycle is taken from, or a copy of the config settings
|
||||
|
||||
--- @class ExpScenario_Vlayer
|
||||
local Vlayer = {
|
||||
--- @package
|
||||
events = {},
|
||||
--- @package
|
||||
on_nth_tick = {},
|
||||
}
|
||||
|
||||
--- The properties of every allowed item, modded items are derived from their base game equivalent
|
||||
local allowed_items = {} --- @type table<string, Vlayer.ItemProperties>
|
||||
for name, properties in pairs(config.allowed_items) do
|
||||
allowed_items[name] = properties
|
||||
end
|
||||
for name, properties in pairs(config.modded_items) do
|
||||
local base = config.allowed_items[properties.base_game_equivalent]
|
||||
local multiplier = properties.multiplier
|
||||
allowed_items[name] = {
|
||||
starting_value = properties.starting_value or 0,
|
||||
required_area = base.required_area or 0,
|
||||
surface_area = (base.surface_area or 0) * multiplier,
|
||||
production = (base.production or 0) * multiplier,
|
||||
capacity = (base.capacity or 0) * multiplier,
|
||||
}
|
||||
end
|
||||
|
||||
--- @type ExpScenario_Vlayer.Data
|
||||
local vlayer_data = {
|
||||
interfaces = {
|
||||
energy = {},
|
||||
circuit = {},
|
||||
storage_input = {},
|
||||
storage_output = {},
|
||||
},
|
||||
properties = {
|
||||
total_surface_area = 0,
|
||||
used_surface_area = 0,
|
||||
total_production = 0,
|
||||
production = 0,
|
||||
discharge = 0,
|
||||
capacity = 0,
|
||||
},
|
||||
storage = {
|
||||
items = {},
|
||||
unallocated = {},
|
||||
power_items = {},
|
||||
energy = 0,
|
||||
},
|
||||
surface = table.deep_copy(config.surface),
|
||||
}
|
||||
|
||||
Storage.register(vlayer_data, function(tbl)
|
||||
vlayer_data = tbl
|
||||
end)
|
||||
|
||||
--- Interface entities are neutral so players can not mine them, these are the prototypes used for each type
|
||||
local interface_names = {
|
||||
energy = "electric-energy-interface",
|
||||
circuit = "constant-combinator",
|
||||
storage_input = "storage-chest",
|
||||
storage_output = "requester-chest",
|
||||
} --- @type table<ExpScenario_Vlayer.InterfaceType, string>
|
||||
|
||||
local interface_types = {} --- @type table<string, ExpScenario_Vlayer.InterfaceType>
|
||||
for interface_type, name in pairs(interface_names) do
|
||||
interface_types[name] = interface_type
|
||||
end
|
||||
|
||||
--- Statistics exposed on circuit interfaces and the signal each is sent as
|
||||
local circuit_signals = {
|
||||
total_surface_area = "signal-A",
|
||||
used_surface_area = "signal-U",
|
||||
remaining_surface_area = "signal-R",
|
||||
production_multiplier = "signal-M",
|
||||
energy_production = "signal-P",
|
||||
energy_sustained = "signal-S",
|
||||
energy_capacity = "signal-C",
|
||||
energy_storage = "signal-E",
|
||||
} --- @type table<string, string>
|
||||
|
||||
local circuit_description = {}
|
||||
for stat_name, signal_name in pairs(circuit_signals) do
|
||||
circuit_description[#circuit_description + 1] = string.format("[virtual-signal=%s] = %s", signal_name, stat_name:gsub("_", " "))
|
||||
end
|
||||
circuit_description = table.concat(circuit_description, "\n")
|
||||
|
||||
--- Get every stored item keyed by name, allocated or not
|
||||
--- @return table<string, number>
|
||||
function Vlayer.get_items()
|
||||
return vlayer_data.storage.items
|
||||
end
|
||||
|
||||
--- Get the items waiting for surface area keyed by name
|
||||
--- @return table<string, number>
|
||||
function Vlayer.get_unallocated_items()
|
||||
return vlayer_data.storage.unallocated
|
||||
end
|
||||
|
||||
--- Get the items which contribute to the properties keyed by name
|
||||
--- @return table<string, number>
|
||||
function Vlayer.get_allocated_items()
|
||||
local allocated = {}
|
||||
local unallocated = vlayer_data.storage.unallocated
|
||||
for name, count in pairs(vlayer_data.storage.items) do
|
||||
allocated[name] = count - (unallocated[name] or 0)
|
||||
end
|
||||
return allocated
|
||||
end
|
||||
|
||||
--- Get the interface entities of each type, do not modify
|
||||
--- @return ExpScenario_Vlayer.Interfaces
|
||||
function Vlayer.get_interfaces()
|
||||
return vlayer_data.interfaces
|
||||
end
|
||||
|
||||
--- Get the signal each statistic is sent as on circuit interfaces
|
||||
--- @return table<string, string>
|
||||
function Vlayer.get_circuits()
|
||||
return circuit_signals
|
||||
end
|
||||
|
||||
--- Surface area left once the unallocated items have taken what they need
|
||||
--- @return number
|
||||
local function get_remaining_surface_area()
|
||||
local properties = vlayer_data.properties
|
||||
local remaining = properties.total_surface_area - properties.used_surface_area
|
||||
for name, count in pairs(vlayer_data.storage.unallocated) do
|
||||
remaining = remaining - allowed_items[name].required_area * count
|
||||
end
|
||||
return remaining
|
||||
end
|
||||
|
||||
--- Fraction of solar production available right now, from the darkness of a real surface or the config day cycle
|
||||
--- @return number
|
||||
local function get_production_multiplier()
|
||||
local surface = vlayer_data.surface
|
||||
local multiplier = surface.solar_power_multiplier
|
||||
if surface.always_day then
|
||||
return multiplier
|
||||
end
|
||||
|
||||
if surface.darkness then
|
||||
local brightness = 1 - surface.darkness
|
||||
if brightness < surface.min_brightness then
|
||||
return 0
|
||||
end
|
||||
return multiplier * (brightness - surface.min_brightness) / (1 - surface.min_brightness)
|
||||
end
|
||||
|
||||
local daytime = (game.tick % surface.ticks_per_day) / surface.ticks_per_day
|
||||
surface.daytime = daytime
|
||||
if daytime <= surface.dusk then
|
||||
return multiplier
|
||||
elseif daytime <= surface.evening then
|
||||
return multiplier * (1 - (daytime - surface.dusk) / (surface.evening - surface.dusk))
|
||||
elseif daytime <= surface.morning then
|
||||
return 0
|
||||
elseif daytime <= surface.dawn then
|
||||
return multiplier * (daytime - surface.morning) / (surface.dawn - surface.morning)
|
||||
end
|
||||
return multiplier
|
||||
end
|
||||
|
||||
--- Fraction of solar production averaged over a whole day, sunrise and sunset count for half
|
||||
--- @return number
|
||||
local function get_sustained_multiplier()
|
||||
local surface = vlayer_data.surface
|
||||
local multiplier = surface.solar_power_multiplier
|
||||
if surface.always_day then
|
||||
return multiplier
|
||||
end
|
||||
|
||||
local day_duration = 1 - surface.dawn + surface.dusk
|
||||
local sunset_duration = surface.evening - surface.dusk
|
||||
local sunrise_duration = surface.dawn - surface.morning
|
||||
return multiplier * (day_duration + 0.5 * (sunset_duration + sunrise_duration))
|
||||
end
|
||||
|
||||
--- Apply the properties of an item to the layer, a negative count deallocates
|
||||
--- @param name string
|
||||
--- @param count number
|
||||
local function allocate_item(name, count)
|
||||
local item = allowed_items[name]
|
||||
local properties = vlayer_data.properties
|
||||
if item.production then
|
||||
properties.production = properties.production + item.production * count
|
||||
properties.total_production = properties.total_production + item.production * count
|
||||
end
|
||||
if item.capacity then
|
||||
properties.capacity = properties.capacity + item.capacity * count
|
||||
end
|
||||
if item.discharge then
|
||||
properties.discharge = properties.discharge + item.discharge * count
|
||||
end
|
||||
if item.surface_area then
|
||||
properties.total_surface_area = properties.total_surface_area + item.surface_area * count
|
||||
end
|
||||
if item.required_area > 0 then
|
||||
properties.used_surface_area = properties.used_surface_area + item.required_area * count
|
||||
end
|
||||
end
|
||||
|
||||
--- Count the production of items which are stored but not allocated, so the total shows what more surface area would give
|
||||
--- @param name string
|
||||
--- @param count number
|
||||
local function count_unallocated_production(name, count)
|
||||
local item = allowed_items[name]
|
||||
if item.production then
|
||||
vlayer_data.properties.total_production = vlayer_data.properties.total_production + item.production * count
|
||||
end
|
||||
end
|
||||
|
||||
for name, item in pairs(allowed_items) do
|
||||
vlayer_data.storage.items[name] = item.starting_value
|
||||
if item.required_area > 0 then
|
||||
vlayer_data.storage.unallocated[name] = 0
|
||||
end
|
||||
if item.power then
|
||||
vlayer_data.storage.power_items[name] = { value = assert(item.fuel_value) * mega, count = 0 }
|
||||
end
|
||||
allocate_item(name, item.starting_value)
|
||||
end
|
||||
|
||||
--- Store an item, it is allocated straight away when there is surface area for it
|
||||
--- @param name string
|
||||
--- @param count number
|
||||
function Vlayer.insert_item(name, count)
|
||||
local item = assert(allowed_items[name], "Item not allowed in the vlayer: " .. name)
|
||||
local storage = vlayer_data.storage
|
||||
storage.items[name] = storage.items[name] + count
|
||||
|
||||
if config.unlimited_surface_area or item.required_area == 0 then
|
||||
allocate_item(name, count)
|
||||
return
|
||||
end
|
||||
|
||||
local properties = vlayer_data.properties
|
||||
local surplus_area = properties.total_surface_area - properties.used_surface_area
|
||||
local allocated = min(count, floor(surplus_area / item.required_area))
|
||||
if allocated > 0 then
|
||||
allocate_item(name, allocated)
|
||||
end
|
||||
|
||||
local unallocated = count - allocated
|
||||
storage.unallocated[name] = storage.unallocated[name] + unallocated
|
||||
count_unallocated_production(name, unallocated)
|
||||
end
|
||||
|
||||
--- Take an item out, unallocated items go first and landfill can only go while nothing is using its area
|
||||
--- @param name string
|
||||
--- @param count number
|
||||
--- @return number # The count actually removed
|
||||
function Vlayer.remove_item(name, count)
|
||||
local item = assert(allowed_items[name], "Item not allowed in the vlayer: " .. name)
|
||||
local storage = vlayer_data.storage
|
||||
local properties = vlayer_data.properties
|
||||
local removed = 0
|
||||
|
||||
if not config.unlimited_surface_area and item.required_area > 0 then
|
||||
removed = min(count, storage.unallocated[name])
|
||||
storage.items[name] = storage.items[name] - removed
|
||||
storage.unallocated[name] = storage.unallocated[name] - removed
|
||||
count_unallocated_production(name, -removed)
|
||||
count = count - removed
|
||||
if count == 0 then
|
||||
return removed
|
||||
end
|
||||
end
|
||||
|
||||
local deallocate = min(count, storage.items[name])
|
||||
if item.surface_area and item.surface_area > 0 then
|
||||
local surplus_area = properties.total_surface_area - properties.used_surface_area
|
||||
deallocate = min(deallocate, floor(surplus_area / item.surface_area))
|
||||
if deallocate <= 0 then
|
||||
return removed
|
||||
end
|
||||
end
|
||||
|
||||
storage.items[name] = storage.items[name] - deallocate
|
||||
allocate_item(name, -deallocate)
|
||||
return removed + deallocate
|
||||
end
|
||||
|
||||
--- Add or take energy, used by other modules which spend the stored energy
|
||||
--- @param energy number J, negative to take
|
||||
--- @return number # J stored afterwards
|
||||
function Vlayer.energy_changed(energy)
|
||||
local storage = vlayer_data.storage
|
||||
storage.energy = storage.energy + energy
|
||||
return storage.energy
|
||||
end
|
||||
|
||||
--- Get the statistics of the layer
|
||||
--- @return ExpScenario_Vlayer.Statistics
|
||||
function Vlayer.get_statistics()
|
||||
local properties = vlayer_data.properties
|
||||
local production = properties.production * mega
|
||||
local production_multiplier = get_production_multiplier()
|
||||
local sustained_multiplier = get_sustained_multiplier()
|
||||
local remaining_surface_area = get_remaining_surface_area()
|
||||
|
||||
return {
|
||||
total_surface_area = properties.total_surface_area,
|
||||
used_surface_area = properties.used_surface_area,
|
||||
remaining_surface_area = remaining_surface_area,
|
||||
surface_area = properties.total_surface_area - remaining_surface_area,
|
||||
production_multiplier = production_multiplier,
|
||||
energy_max = production,
|
||||
energy_production = production * production_multiplier,
|
||||
energy_total_production = properties.total_production * sustained_multiplier * mega,
|
||||
energy_sustained = production * sustained_multiplier,
|
||||
energy_capacity = properties.capacity * mega,
|
||||
energy_storage = vlayer_data.storage.energy,
|
||||
}
|
||||
end
|
||||
|
||||
--- Make an entity into an interface which players can not mine or damage
|
||||
--- @param interface LuaEntity
|
||||
--- @param interface_type ExpScenario_Vlayer.InterfaceType
|
||||
--- @param player LuaPlayer?
|
||||
local function register_interface(interface, interface_type, player)
|
||||
local interfaces = vlayer_data.interfaces[interface_type]
|
||||
interfaces[#interfaces + 1] = interface
|
||||
interface.last_user = player
|
||||
interface.destructible = false
|
||||
interface.minable_flag = false
|
||||
end
|
||||
|
||||
--- Create an interface which powers the electric network it is placed in
|
||||
--- @param surface LuaSurface
|
||||
--- @param position MapPosition
|
||||
--- @param player LuaPlayer?
|
||||
--- @return LuaEntity? # Nil when the interface does not fit
|
||||
function Vlayer.create_energy_interface(surface, position, player)
|
||||
if not surface.can_place_entity{ name = interface_names.energy, position = position } then
|
||||
return nil
|
||||
end
|
||||
|
||||
local interface = assert(surface.create_entity{ name = interface_names.energy, position = position, force = "neutral" })
|
||||
register_interface(interface, "energy", player)
|
||||
interface.operable = false
|
||||
interface.electric_buffer_size = 0
|
||||
interface.power_production = 0
|
||||
interface.power_usage = 0
|
||||
interface.energy = 0
|
||||
return interface
|
||||
end
|
||||
|
||||
--- Create an interface which outputs the statistics and stored items as signals
|
||||
--- @param surface LuaSurface
|
||||
--- @param position MapPosition
|
||||
--- @param player LuaPlayer?
|
||||
--- @return LuaEntity
|
||||
function Vlayer.create_circuit_interface(surface, position, player)
|
||||
local interface = assert(surface.create_entity{ name = interface_names.circuit, position = position, force = "neutral" })
|
||||
register_interface(interface, "circuit", player)
|
||||
interface.combinator_description = circuit_description
|
||||
return interface
|
||||
end
|
||||
|
||||
--- Create an interface which stores every allowed item put into it
|
||||
--- @param surface LuaSurface
|
||||
--- @param position MapPosition
|
||||
--- @param player LuaPlayer?
|
||||
--- @return LuaEntity
|
||||
function Vlayer.create_input_interface(surface, position, player)
|
||||
local interface = assert(surface.create_entity{ name = interface_names.storage_input, position = position, force = "neutral" })
|
||||
register_interface(interface, "storage_input", player)
|
||||
-- A filter nothing can match stops robots filling it with anything
|
||||
interface.storage_filter = { name = "deconstruction-planner", quality = "normal" }
|
||||
return interface
|
||||
end
|
||||
|
||||
--- Create an interface which takes stored items out to fulfil its requests
|
||||
--- @param surface LuaSurface
|
||||
--- @param position MapPosition
|
||||
--- @param player LuaPlayer?
|
||||
--- @return LuaEntity
|
||||
function Vlayer.create_output_interface(surface, position, player)
|
||||
local interface = assert(surface.create_entity{ name = interface_names.storage_output, position = position, force = "neutral" })
|
||||
register_interface(interface, "storage_output", player)
|
||||
return interface
|
||||
end
|
||||
|
||||
--- Remove an interface, anything it holds is dropped in a chest next to it and stored energy is kept
|
||||
--- @param interface LuaEntity
|
||||
--- @return ExpScenario_Vlayer.InterfaceType
|
||||
function Vlayer.remove_interface(interface)
|
||||
local interface_type = assert(interface_types[interface.name], "Entity is not a vlayer interface: " .. interface.name)
|
||||
if interface_type == "storage_input" or interface_type == "storage_output" then
|
||||
ExpUtil.transfer_inventory_to_surface{
|
||||
inventory = assert(interface.get_inventory(defines.inventory.chest)),
|
||||
surface = interface.surface,
|
||||
name = "iron-chest",
|
||||
allow_creation = true,
|
||||
}
|
||||
elseif interface_type == "energy" then
|
||||
vlayer_data.storage.energy = vlayer_data.storage.energy + interface.energy
|
||||
end
|
||||
|
||||
table.remove_element(vlayer_data.interfaces[interface_type], interface)
|
||||
interface.destroy()
|
||||
return interface_type
|
||||
end
|
||||
|
||||
--- Forget interfaces which no longer exist
|
||||
--- @param interfaces LuaEntity[]
|
||||
local function prune_interfaces(interfaces)
|
||||
for index = #interfaces, 1, -1 do
|
||||
if not interfaces[index].valid then
|
||||
table.remove(interfaces, index)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--- Store the contents of the input interfaces
|
||||
local function handle_input_interfaces()
|
||||
local interfaces = vlayer_data.interfaces.storage_input
|
||||
prune_interfaces(interfaces)
|
||||
for _, interface in ipairs(interfaces) do
|
||||
local inventory = assert(interface.get_inventory(defines.inventory.chest))
|
||||
for _, item in pairs(inventory.get_contents()) do
|
||||
local name = item.name
|
||||
if allowed_items[name] then
|
||||
-- Quality is not tracked, so higher quality is stored as extra normal items in batches of ten
|
||||
local quality_level = prototypes.quality[item.quality].level
|
||||
local removed, stored = 0, 0
|
||||
if quality_level == 0 then
|
||||
removed, stored = item.count, item.count
|
||||
elseif item.count >= 10 then
|
||||
local batches = floor(item.count / 10)
|
||||
removed, stored = batches * 10, batches * (10 + quality_level * 3)
|
||||
end
|
||||
|
||||
if removed > 0 then
|
||||
local modded = config.modded_items[name]
|
||||
if modded and config.modded_auto_downgrade then
|
||||
Vlayer.insert_item(modded.base_game_equivalent, stored * modded.multiplier)
|
||||
elseif vlayer_data.storage.power_items[name] then
|
||||
local power_item = vlayer_data.storage.power_items[name]
|
||||
power_item.count = power_item.count + stored
|
||||
else
|
||||
Vlayer.insert_item(name, stored)
|
||||
end
|
||||
inventory.remove{ name = name, count = removed, quality = item.quality }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--- Fill the requests of the output interfaces from storage
|
||||
local function handle_output_interfaces()
|
||||
local interfaces = vlayer_data.interfaces.storage_output
|
||||
prune_interfaces(interfaces)
|
||||
for _, interface in ipairs(interfaces) do
|
||||
local inventory = assert(interface.get_inventory(defines.inventory.chest))
|
||||
for _, section in ipairs(assert(interface.get_logistic_sections()).sections) do
|
||||
for _, filter in pairs(section.filters) do
|
||||
local name = filter.value and filter.value.name
|
||||
if name and allowed_items[name] then
|
||||
local wanted = min(assert(filter.min) - inventory.get_item_count(name), vlayer_data.storage.items[name])
|
||||
if wanted > 0 and inventory.can_insert{ name = name, count = wanted } then
|
||||
local removed = Vlayer.remove_item(name, wanted)
|
||||
if removed > 0 then
|
||||
inventory.insert{ name = name, count = removed, quality = "normal" }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--- Allocate waiting items in proportion to the surface area that has become available
|
||||
local function handle_unallocated()
|
||||
if config.unlimited_surface_area then return end
|
||||
|
||||
local unallocated_area = 0
|
||||
for name, count in pairs(vlayer_data.storage.unallocated) do
|
||||
unallocated_area = unallocated_area + allowed_items[name].required_area * count
|
||||
end
|
||||
if unallocated_area == 0 then return end
|
||||
|
||||
local properties = vlayer_data.properties
|
||||
local surplus_area = properties.total_surface_area - properties.used_surface_area
|
||||
for name, count in pairs(vlayer_data.storage.unallocated) do
|
||||
local allocated = min(count, floor(count * surplus_area / unallocated_area))
|
||||
if allocated > 0 then
|
||||
vlayer_data.storage.unallocated[name] = count - allocated
|
||||
allocate_item(name, allocated)
|
||||
count_unallocated_production(name, -allocated)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--- Set the signals of the circuit interfaces to the statistics and stored items
|
||||
local function handle_circuit_interfaces()
|
||||
local interfaces = vlayer_data.interfaces.circuit
|
||||
prune_interfaces(interfaces)
|
||||
if #interfaces == 0 then return end
|
||||
|
||||
local stats = Vlayer.get_statistics()
|
||||
for _, interface in ipairs(interfaces) do
|
||||
local control = interface.get_or_create_control_behavior() --[[@as LuaConstantCombinatorControlBehavior]]
|
||||
if control.sections_count == 0 then
|
||||
control.add_section()
|
||||
end
|
||||
local section = assert(control.sections[1])
|
||||
|
||||
-- Slots are cleared first because an item can not be set in two slots at once
|
||||
for index = section.filters_count, 1, -1 do
|
||||
section.clear_slot(index)
|
||||
end
|
||||
|
||||
local index = 1
|
||||
for stat_name, signal_name in pairs(circuit_signals) do
|
||||
local value = stats[stat_name] --[[@as number]]
|
||||
if stat_name:find("energy") then
|
||||
value = value / mega
|
||||
elseif stat_name == "production_multiplier" then
|
||||
value = value * 10000
|
||||
end
|
||||
section.set_slot(index, { value = { type = "virtual", name = signal_name, quality = "normal" }, min = floor(value) })
|
||||
index = index + 1
|
||||
end
|
||||
|
||||
for name, count in pairs(vlayer_data.storage.items) do
|
||||
if count > 0 and prototypes.item[name] then
|
||||
section.set_slot(index, { value = { type = "item", name = name, quality = "normal" }, min = count })
|
||||
index = index + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--- Produce energy, share it between the energy interfaces, and burn fuel when storage runs low
|
||||
local function handle_energy_interfaces()
|
||||
local storage = vlayer_data.storage
|
||||
local properties = vlayer_data.properties
|
||||
local production = properties.production * mega * (config.update_tick_energy / 60)
|
||||
storage.energy = storage.energy + floor(production * get_production_multiplier())
|
||||
|
||||
local interfaces = vlayer_data.interfaces.energy
|
||||
prune_interfaces(interfaces)
|
||||
if #interfaces > 0 then
|
||||
local available_energy = storage.energy
|
||||
for _, interface in ipairs(interfaces) do
|
||||
available_energy = available_energy + interface.energy
|
||||
end
|
||||
|
||||
local discharge_rate = 2 * (production + properties.discharge * mega) / #interfaces
|
||||
local fill_to = min(discharge_rate, floor(available_energy / #interfaces))
|
||||
for _, interface in ipairs(interfaces) do
|
||||
interface.electric_buffer_size = max(discharge_rate, interface.energy) -- A smaller buffer would lose energy
|
||||
local delta = fill_to - interface.energy
|
||||
storage.energy = storage.energy - delta
|
||||
interface.energy = interface.energy + delta
|
||||
end
|
||||
end
|
||||
|
||||
local capacity = properties.capacity * mega
|
||||
if not config.unlimited_capacity and storage.energy > capacity then
|
||||
storage.energy = capacity
|
||||
return
|
||||
end
|
||||
|
||||
for _, power_item in pairs(storage.power_items) do
|
||||
local max_burn = capacity / 2 - storage.energy
|
||||
if power_item.count > 0 and max_burn > 0 then
|
||||
local burn = min(power_item.count, floor(max_burn / power_item.value))
|
||||
storage.energy = storage.energy + burn * power_item.value
|
||||
power_item.count = power_item.count - burn
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--- Take the day cycle from the mimic surface when it exists, otherwise from the config
|
||||
local function update_surface()
|
||||
if config.mimic_surface then
|
||||
local surface = game.get_surface(config.mimic_surface)
|
||||
if surface then
|
||||
vlayer_data.surface = surface
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
-- The config copy never has an index, so this avoids replacing it every time a surface changes
|
||||
if not vlayer_data.surface.index then
|
||||
vlayer_data.surface = table.deep_copy(config.surface)
|
||||
end
|
||||
end
|
||||
|
||||
--- Move items between the interfaces and storage
|
||||
local function update_storage()
|
||||
handle_input_interfaces()
|
||||
handle_output_interfaces()
|
||||
handle_unallocated()
|
||||
end
|
||||
|
||||
--- Update the signals and energy of the interfaces
|
||||
local function update_energy()
|
||||
handle_circuit_interfaces()
|
||||
handle_energy_interfaces()
|
||||
end
|
||||
|
||||
local e = defines.events
|
||||
|
||||
Vlayer.on_init = update_surface -- The default surface exists before on_surface_created can fire
|
||||
Vlayer.events[e.on_surface_created] = update_surface
|
||||
Vlayer.events[e.on_surface_renamed] = update_surface
|
||||
Vlayer.events[e.on_surface_imported] = update_surface
|
||||
Vlayer.on_nth_tick[config.update_tick_storage] = update_storage
|
||||
Vlayer.on_nth_tick[config.update_tick_energy] = update_energy
|
||||
|
||||
return Vlayer
|
||||
@@ -5,7 +5,7 @@ Adds a gui that allows players to apply various bonuses
|
||||
local Gui = require("modules/exp_gui")
|
||||
local Roles = require("modules/exp_roles")
|
||||
local config = require("modules/exp_legacy/config/bonus")
|
||||
local vlayer = require("modules/exp_legacy/modules/control/vlayer")
|
||||
local Vlayer = require("modules/exp_scenario/control/vlayer")
|
||||
local format_number = require("util").format_number
|
||||
|
||||
--- @class ExpGui_PlayerBonus.elements
|
||||
@@ -486,7 +486,7 @@ end
|
||||
--- Apply periodic bonus to a player
|
||||
--- @param player LuaPlayer
|
||||
local function apply_personal_battery_recharge(player)
|
||||
local available_energy = vlayer.get_statistics()["energy_storage"]
|
||||
local available_energy = Vlayer.get_statistics().energy_storage
|
||||
if available_energy <= 0 then
|
||||
return -- No power to give
|
||||
end
|
||||
@@ -508,7 +508,7 @@ local function apply_personal_battery_recharge(player)
|
||||
local energy_to_give = math.min(math.floor(equipment.max_energy - equipment.energy), available_energy, recharge_amount)
|
||||
equipment.energy = equipment.energy + energy_to_give
|
||||
recharge_amount = recharge_amount - energy_to_give
|
||||
available_energy = vlayer.energy_changed(-energy_to_give)
|
||||
available_energy = Vlayer.energy_changed(-energy_to_give)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -117,7 +117,7 @@ Elements.player_stats_table = Gui.define("player_stats/data_table")
|
||||
width = 135,
|
||||
})
|
||||
labels[stat_name] = Elements.table_label(data_table, {
|
||||
caption = { "readme.data-format", value, metadata.unit or "" },
|
||||
caption = { "exp-gui_readme.data-format", value, metadata.unit or "" },
|
||||
tooltip = metadata.value_tooltip or { "exp-statistics." .. stat_name .. "-tooltip" },
|
||||
width = 105,
|
||||
})
|
||||
@@ -131,7 +131,7 @@ Elements.player_stats_table = Gui.define("player_stats/data_table")
|
||||
width = 135,
|
||||
})
|
||||
labels[stat_name] = Elements.table_label(data_table, {
|
||||
caption = { "readme.data-format", data.default, "" },
|
||||
caption = { "exp-gui_readme.data-format", data.default, "" },
|
||||
tooltip = { "exp-statistics." .. stat_name .. "-tooltip" },
|
||||
width = 105,
|
||||
})
|
||||
|
||||
@@ -189,7 +189,7 @@ define_tab(
|
||||
local player = Gui.get_player(parent)
|
||||
|
||||
local server_details = {
|
||||
name = "ExpGaming S0 - Local",
|
||||
name = config_server_detail["community_name"] .. " S0 - Local",
|
||||
welcome = "Failed to load description: disconnected from external api.",
|
||||
reset_time = "Not Set",
|
||||
}
|
||||
@@ -338,7 +338,7 @@ define_tab(
|
||||
local external_links = Elements.title_table(scroll_pane, 235, { "exp-gui_readme.servers-external" }, 2)
|
||||
for _, key in ipairs{ "discord", "website", "patreon", "status", "github" } do
|
||||
Gui.elements.centered_label(external_links, 110, key:gsub("^%l", string.upper))
|
||||
Gui.elements.centered_label(external_links, 460, { "links." .. key }, { "exp-gui_readme.servers-open-in-browser" })
|
||||
Gui.elements.centered_label(external_links, 460, config_server_detail[key], { "exp-gui_readme.servers-open-in-browser" })
|
||||
end
|
||||
|
||||
return container
|
||||
|
||||
@@ -0,0 +1,531 @@
|
||||
--[[-- Gui - Virtual Layer
|
||||
Shows what the virtual layer holds and lets players build and remove its interfaces
|
||||
]]
|
||||
|
||||
local Gui = require("modules/exp_gui")
|
||||
local Roles = require("modules/exp_roles")
|
||||
local Colors = require("modules/exp_util/include/color")
|
||||
local config = require("modules.exp_legacy.config.vlayer")
|
||||
local Vlayer = require("modules/exp_scenario/control/vlayer")
|
||||
local format_number = require("util").format_number
|
||||
|
||||
local Selection = require("modules/exp_util/selection")
|
||||
local SelectArea = Selection.connect("ExpGui_Vlayer")
|
||||
|
||||
local floor = math.floor
|
||||
local ceil = math.ceil
|
||||
local max = math.max
|
||||
local format_string = string.format
|
||||
|
||||
--- @class ExpGui_Vlayer.elements
|
||||
local Elements = {}
|
||||
|
||||
--- Interface types in the order the type dropdown lists them
|
||||
local interface_types = { "energy", "circuit", "storage_input", "storage_output" } --- @type ExpScenario_Vlayer.InterfaceType[]
|
||||
|
||||
--- Locale key of each interface type
|
||||
local type_captions = {} --- @type table<ExpScenario_Vlayer.InterfaceType, LocalisedString>
|
||||
for _, interface_type in ipairs(interface_types) do
|
||||
type_captions[interface_type] = { "exp-gui_vlayer.type-" .. interface_type:gsub("_", "-") }
|
||||
end
|
||||
|
||||
--- Statistics shown as progress bars, in display order
|
||||
--- @type { name: string, caption: LocalisedString, tooltip: LocalisedString }[]
|
||||
local stats = {}
|
||||
for _, name in ipairs{ "solar", "accumulator", "surface-area", "sustained", "production", "capacity" } do
|
||||
stats[#stats + 1] = {
|
||||
name = name,
|
||||
caption = { "exp-gui_vlayer.caption-stat-" .. name },
|
||||
tooltip = { "exp-gui_vlayer.tooltip-stat-" .. name },
|
||||
}
|
||||
end
|
||||
|
||||
local energy_suffixes = {
|
||||
{ 1e15, "P" }, { 1e12, "T" }, { 1e9, "G" }, { 1e6, "M" }, { 1e3, "k" },
|
||||
}
|
||||
|
||||
--- Format an amount of energy with an SI prefix, util.format_number uses B for giga
|
||||
--- @param amount number
|
||||
--- @param unit string
|
||||
--- @return string
|
||||
local function format_energy(amount, unit)
|
||||
if amount < 1 then
|
||||
return "0 " .. unit
|
||||
end
|
||||
for _, suffix in ipairs(energy_suffixes) do
|
||||
if amount >= suffix[1] then
|
||||
return format_string("%.1f %s%s", amount / suffix[1], suffix[2], unit)
|
||||
end
|
||||
end
|
||||
return format_number(floor(amount), false) .. " " .. unit
|
||||
end
|
||||
|
||||
--- Expand an area to whole tiles
|
||||
--- @param area BoundingBox
|
||||
--- @return BoundingBox
|
||||
local function expand_area(area)
|
||||
return {
|
||||
left_top = { x = floor(area.left_top.x), y = floor(area.left_top.y) },
|
||||
right_bottom = { x = ceil(area.right_bottom.x), y = ceil(area.right_bottom.y) },
|
||||
}
|
||||
end
|
||||
|
||||
--- Rich text link to a position
|
||||
--- @param position MapPosition
|
||||
--- @param surface LuaSurface
|
||||
--- @return string
|
||||
local function gps_string(position, surface)
|
||||
return format_string("[gps=%.1f,%.1f,%s]", position.x, position.y, surface.name)
|
||||
end
|
||||
|
||||
--- Label naming a statistic
|
||||
--- @class ExpGui_Vlayer.elements.stat_label: ExpElement
|
||||
--- @overload fun(parent: LuaGuiElement, caption: LocalisedString, tooltip: LocalisedString): LuaGuiElement
|
||||
Elements.stat_label = Gui.define("vlayer/stat_label")
|
||||
:draw{
|
||||
type = "label",
|
||||
caption = Gui.from_argument(1),
|
||||
tooltip = Gui.from_argument(2),
|
||||
style = "heading_2_label",
|
||||
}
|
||||
:style{
|
||||
width = 200,
|
||||
} --[[@as any]]
|
||||
|
||||
--- Bar showing a statistic as a fraction with the values as its caption
|
||||
--- @class ExpGui_Vlayer.elements.stat_bar: ExpElement
|
||||
--- @overload fun(parent: LuaGuiElement): LuaGuiElement
|
||||
Elements.stat_bar = Gui.define("vlayer/stat_bar")
|
||||
:draw{
|
||||
type = "progressbar",
|
||||
caption = "",
|
||||
value = 0,
|
||||
style = "electric_satisfaction_statistics_progressbar",
|
||||
}
|
||||
:style{
|
||||
width = 200,
|
||||
font = "heading-2",
|
||||
} --[[@as any]]
|
||||
|
||||
--- @class ExpGui_Vlayer.elements.stat_bar.display_data
|
||||
--- @field value number Fraction the bar is filled
|
||||
--- @field caption string
|
||||
|
||||
--- Refresh a bar
|
||||
--- @param stat_bar LuaGuiElement
|
||||
--- @param display_data ExpGui_Vlayer.elements.stat_bar.display_data
|
||||
function Elements.stat_bar.refresh(stat_bar, display_data)
|
||||
stat_bar.value = display_data.value
|
||||
stat_bar.caption = display_data.caption
|
||||
end
|
||||
|
||||
--- Table of a label and bar for each statistic
|
||||
--- @class ExpGui_Vlayer.elements.stats_table: ExpElement
|
||||
--- @field data table<LuaGuiElement, table<string, LuaGuiElement>> Bars keyed by statistic name
|
||||
--- @overload fun(parent: LuaGuiElement): LuaGuiElement
|
||||
Elements.stats_table = Gui.define("vlayer/stats_table")
|
||||
:track_all_elements()
|
||||
:draw(function(def, parent)
|
||||
--- @cast def ExpGui_Vlayer.elements.stats_table
|
||||
local stats_table = Gui.elements.scroll_table(parent, 400, 2, "stats")
|
||||
local stat_bars = {}
|
||||
for _, stat in ipairs(stats) do
|
||||
Elements.stat_label(stats_table, stat.caption, stat.tooltip)
|
||||
stat_bars[stat.name] = Elements.stat_bar(stats_table)
|
||||
end
|
||||
def.data[stats_table] = stat_bars
|
||||
return stats_table
|
||||
end) --[[@as any]]
|
||||
|
||||
--- Calculate the display data of every statistic, the same for every player
|
||||
--- @return table<string, ExpGui_Vlayer.elements.stat_bar.display_data>
|
||||
function Elements.stats_table.calculate_display_data()
|
||||
local statistics = Vlayer.get_statistics()
|
||||
local items = Vlayer.get_items()
|
||||
local allocated = Vlayer.get_allocated_items()
|
||||
return {
|
||||
solar = {
|
||||
value = allocated["solar-panel"] / max(items["solar-panel"], 1),
|
||||
caption = format_number(allocated["solar-panel"], false) .. " / " .. format_number(items["solar-panel"], false),
|
||||
},
|
||||
accumulator = {
|
||||
value = allocated["accumulator"] / max(items["accumulator"], 1),
|
||||
caption = format_number(allocated["accumulator"], false) .. " / " .. format_number(items["accumulator"], false),
|
||||
},
|
||||
["surface-area"] = {
|
||||
value = statistics.total_surface_area / max(statistics.surface_area, 1),
|
||||
caption = format_number(statistics.remaining_surface_area, false),
|
||||
},
|
||||
sustained = {
|
||||
value = statistics.energy_sustained / max(statistics.energy_total_production, 1),
|
||||
caption = format_energy(statistics.energy_sustained, "W") .. " / " .. format_energy(statistics.energy_total_production, "W"),
|
||||
},
|
||||
production = {
|
||||
value = statistics.energy_production / max(statistics.energy_max, 1),
|
||||
caption = format_energy(statistics.energy_production, "W") .. " / " .. format_energy(statistics.energy_max, "W"),
|
||||
},
|
||||
capacity = {
|
||||
value = statistics.energy_storage / max(statistics.energy_capacity, 1),
|
||||
caption = format_energy(statistics.energy_storage, "J") .. " / " .. format_energy(statistics.energy_capacity, "J"),
|
||||
},
|
||||
}
|
||||
end
|
||||
|
||||
--- Refresh every bar of a table
|
||||
--- @param stats_table LuaGuiElement
|
||||
--- @param display_data table<string, ExpGui_Vlayer.elements.stat_bar.display_data>
|
||||
function Elements.stats_table.refresh(stats_table, display_data)
|
||||
for name, stat_bar in pairs(Elements.stats_table.data[stats_table]) do
|
||||
Elements.stat_bar.refresh(stat_bar, display_data[name])
|
||||
end
|
||||
end
|
||||
|
||||
--- Refresh the tables of every online player
|
||||
function Elements.stats_table.refresh_online()
|
||||
local display_data = Elements.stats_table.calculate_display_data()
|
||||
for _, stats_table in Elements.stats_table:online_elements() do
|
||||
Elements.stats_table.refresh(stats_table, display_data)
|
||||
end
|
||||
end
|
||||
|
||||
--- @class ExpGui_Vlayer.elements.type_dropdown.element_data
|
||||
--- @field controls LuaGuiElement
|
||||
|
||||
--- Dropdown which picks the type of interface to build or list
|
||||
--- @class ExpGui_Vlayer.elements.type_dropdown: ExpElement
|
||||
--- @field data table<LuaGuiElement, ExpGui_Vlayer.elements.type_dropdown.element_data>
|
||||
--- @overload fun(parent: LuaGuiElement, controls: LuaGuiElement): LuaGuiElement
|
||||
Elements.type_dropdown = Gui.define("vlayer/type_dropdown")
|
||||
:draw{
|
||||
type = "drop-down",
|
||||
items = { type_captions.energy, type_captions.circuit, type_captions.storage_input, type_captions.storage_output },
|
||||
selected_index = 1,
|
||||
}
|
||||
:style{
|
||||
width = 200,
|
||||
}
|
||||
:element_data{
|
||||
controls = Gui.from_argument(1),
|
||||
}
|
||||
:on_selection_state_changed(function(def, _, type_dropdown)
|
||||
--- @cast def ExpGui_Vlayer.elements.type_dropdown
|
||||
Elements.controls.refresh_interfaces(def.data[type_dropdown].controls)
|
||||
end) --[[@as any]]
|
||||
|
||||
--- Get the selected interface type
|
||||
--- @param type_dropdown LuaGuiElement
|
||||
--- @return ExpScenario_Vlayer.InterfaceType
|
||||
function Elements.type_dropdown.get_selected(type_dropdown)
|
||||
return (assert(interface_types[type_dropdown.selected_index]))
|
||||
end
|
||||
|
||||
--- Dropdown listing the interfaces of the selected type by position
|
||||
--- @class ExpGui_Vlayer.elements.interface_dropdown: ExpElement
|
||||
--- @overload fun(parent: LuaGuiElement): LuaGuiElement
|
||||
Elements.interface_dropdown = Gui.define("vlayer/interface_dropdown")
|
||||
:draw{
|
||||
type = "drop-down",
|
||||
}
|
||||
:style{
|
||||
width = 200,
|
||||
} --[[@as any]]
|
||||
|
||||
--- Refresh the listed interfaces
|
||||
--- @param interface_dropdown LuaGuiElement
|
||||
--- @param interfaces LuaEntity[]
|
||||
function Elements.interface_dropdown.refresh(interface_dropdown, interfaces)
|
||||
local items = {}
|
||||
for index, interface in ipairs(interfaces) do
|
||||
local position = interface.position
|
||||
items[index] = format_string("%d X %.1f Y %.1f", index, position.x, position.y)
|
||||
end
|
||||
interface_dropdown.items = items
|
||||
end
|
||||
|
||||
--- Get the selected interface
|
||||
--- @param interface_dropdown LuaGuiElement
|
||||
--- @param interfaces LuaEntity[]
|
||||
--- @return LuaEntity?
|
||||
function Elements.interface_dropdown.get_selected(interface_dropdown, interfaces)
|
||||
local interface = interfaces[interface_dropdown.selected_index]
|
||||
if interface and interface.valid then
|
||||
return interface
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
--- @class ExpGui_Vlayer.elements.control_button.element_data
|
||||
--- @field controls LuaGuiElement
|
||||
|
||||
--- Button which refreshes the listed interfaces
|
||||
--- @class ExpGui_Vlayer.elements.refresh_button: ExpElement
|
||||
--- @field data table<LuaGuiElement, ExpGui_Vlayer.elements.control_button.element_data>
|
||||
--- @overload fun(parent: LuaGuiElement, controls: LuaGuiElement): LuaGuiElement
|
||||
Elements.refresh_button = Gui.define("vlayer/refresh_button")
|
||||
:draw{
|
||||
type = "button",
|
||||
caption = { "exp-gui_vlayer.caption-refresh" },
|
||||
}
|
||||
:style{
|
||||
width = 200,
|
||||
}
|
||||
:element_data{
|
||||
controls = Gui.from_argument(1),
|
||||
}
|
||||
:on_click(function(def, _, refresh_button)
|
||||
--- @cast def ExpGui_Vlayer.elements.refresh_button
|
||||
Elements.controls.refresh_interfaces(def.data[refresh_button].controls)
|
||||
end) --[[@as any]]
|
||||
|
||||
--- Button which opens the map at the selected interface
|
||||
--- @class ExpGui_Vlayer.elements.view_button: ExpElement
|
||||
--- @field data table<LuaGuiElement, ExpGui_Vlayer.elements.control_button.element_data>
|
||||
--- @overload fun(parent: LuaGuiElement, controls: LuaGuiElement): LuaGuiElement
|
||||
Elements.view_button = Gui.define("vlayer/view_button")
|
||||
:draw{
|
||||
type = "button",
|
||||
caption = { "exp-gui_vlayer.caption-view" },
|
||||
}
|
||||
:style{
|
||||
width = 200,
|
||||
}
|
||||
:element_data{
|
||||
controls = Gui.from_argument(1),
|
||||
}
|
||||
:on_click(function(def, player, view_button)
|
||||
--- @cast def ExpGui_Vlayer.elements.view_button
|
||||
local controls = def.data[view_button].controls
|
||||
local interface_type, interface = Elements.controls.get_selected_interface(controls)
|
||||
if not interface then return end
|
||||
player.set_controller{ type = defines.controllers.remote, position = interface.position, surface = interface.surface }
|
||||
player.print{ "exp-gui_vlayer.message-located", type_captions[interface_type], gps_string(interface.position, interface.surface) }
|
||||
end) --[[@as any]]
|
||||
|
||||
--- Button which toggles selecting an area to build an interface in
|
||||
--- @class ExpGui_Vlayer.elements.build_button: ExpElement
|
||||
--- @overload fun(parent: LuaGuiElement): LuaGuiElement
|
||||
Elements.build_button = Gui.define("vlayer/build_button")
|
||||
:track_all_elements()
|
||||
:draw{
|
||||
type = "button",
|
||||
caption = { "exp-gui_vlayer.caption-build" },
|
||||
}
|
||||
:style{
|
||||
width = 200,
|
||||
}
|
||||
:on_click(function(_, player)
|
||||
if SelectArea:stop(player) then
|
||||
player.print{ "exp_util.selection_exit", { "exp-gui_vlayer.selection-name" } }
|
||||
else
|
||||
SelectArea:start(player)
|
||||
player.print{ "exp_util.selection_enter", { "exp-gui_vlayer.selection-name" } }
|
||||
end
|
||||
end) --[[@as any]]
|
||||
|
||||
--- Button which removes the selected interface
|
||||
--- @class ExpGui_Vlayer.elements.remove_button: ExpElement
|
||||
--- @field data table<LuaGuiElement, ExpGui_Vlayer.elements.control_button.element_data>
|
||||
--- @overload fun(parent: LuaGuiElement, controls: LuaGuiElement): LuaGuiElement
|
||||
Elements.remove_button = Gui.define("vlayer/remove_button")
|
||||
:track_all_elements()
|
||||
:draw{
|
||||
type = "button",
|
||||
caption = { "exp-gui_vlayer.caption-remove" },
|
||||
}
|
||||
:style{
|
||||
width = 200,
|
||||
}
|
||||
:element_data{
|
||||
controls = Gui.from_argument(1),
|
||||
}
|
||||
:on_click(function(def, player, remove_button)
|
||||
--- @cast def ExpGui_Vlayer.elements.remove_button
|
||||
local controls = def.data[remove_button].controls
|
||||
local _, interface = Elements.controls.get_selected_interface(controls)
|
||||
if not interface then return end
|
||||
local position, surface = interface.position, interface.surface
|
||||
local interface_type = Vlayer.remove_interface(interface)
|
||||
game.print{ "exp-gui_vlayer.message-removed", player.name, type_captions[interface_type], gps_string(position, surface) }
|
||||
Elements.controls.refresh_interfaces_online()
|
||||
end) --[[@as any]]
|
||||
|
||||
--- @class ExpGui_Vlayer.elements.controls.element_data
|
||||
--- @field type_dropdown LuaGuiElement
|
||||
--- @field interface_dropdown LuaGuiElement
|
||||
|
||||
--- Table of the dropdowns and buttons used to manage interfaces
|
||||
--- @class ExpGui_Vlayer.elements.controls: ExpElement
|
||||
--- @field data table<LuaGuiElement, ExpGui_Vlayer.elements.controls.element_data>
|
||||
--- @overload fun(parent: LuaGuiElement): LuaGuiElement
|
||||
Elements.controls = Gui.define("vlayer/controls")
|
||||
:track_all_elements()
|
||||
:draw(function(def, parent)
|
||||
--- @cast def ExpGui_Vlayer.elements.controls
|
||||
local controls = Gui.elements.scroll_table(parent, 400, 2, "controls")
|
||||
local player = Gui.get_player(parent)
|
||||
local can_edit = Roles.player_has_permission(player, "exp_scenario.gui.vlayer_edit")
|
||||
|
||||
local type_dropdown = Elements.type_dropdown(controls, controls)
|
||||
local interface_dropdown = Elements.interface_dropdown(controls)
|
||||
Elements.refresh_button(controls, controls)
|
||||
Elements.view_button(controls, controls)
|
||||
Elements.build_button(controls).visible = can_edit
|
||||
Elements.remove_button(controls, controls).visible = can_edit
|
||||
|
||||
def.data[controls] = {
|
||||
type_dropdown = type_dropdown,
|
||||
interface_dropdown = interface_dropdown,
|
||||
}
|
||||
Elements.controls.refresh_interfaces(controls)
|
||||
return controls
|
||||
end) --[[@as any]]
|
||||
|
||||
--- Get the selected interface type
|
||||
--- @param controls LuaGuiElement
|
||||
--- @return ExpScenario_Vlayer.InterfaceType
|
||||
function Elements.controls.get_selected_type(controls)
|
||||
return Elements.type_dropdown.get_selected(Elements.controls.data[controls].type_dropdown)
|
||||
end
|
||||
|
||||
--- Get the selected interface and its type
|
||||
--- @param controls LuaGuiElement
|
||||
--- @return ExpScenario_Vlayer.InterfaceType, LuaEntity?
|
||||
function Elements.controls.get_selected_interface(controls)
|
||||
local elements = Elements.controls.data[controls]
|
||||
local interface_type = Elements.type_dropdown.get_selected(elements.type_dropdown)
|
||||
local interfaces = Vlayer.get_interfaces()[interface_type]
|
||||
return interface_type, Elements.interface_dropdown.get_selected(elements.interface_dropdown, interfaces)
|
||||
end
|
||||
|
||||
--- Refresh the listed interfaces to match the selected type
|
||||
--- @param controls LuaGuiElement
|
||||
function Elements.controls.refresh_interfaces(controls)
|
||||
local elements = Elements.controls.data[controls]
|
||||
local interface_type = Elements.type_dropdown.get_selected(elements.type_dropdown)
|
||||
Elements.interface_dropdown.refresh(elements.interface_dropdown, Vlayer.get_interfaces()[interface_type])
|
||||
end
|
||||
|
||||
--- Refresh the listed interfaces of every online player, used when an interface is built or removed
|
||||
function Elements.controls.refresh_interfaces_online()
|
||||
for _, controls in Elements.controls:online_elements() do
|
||||
Elements.controls.refresh_interfaces(controls)
|
||||
end
|
||||
end
|
||||
|
||||
--- Refresh whether a player can see the edit buttons
|
||||
--- @param player LuaPlayer
|
||||
function Elements.controls.refresh_permissions(player)
|
||||
local can_edit = Roles.player_has_permission(player, "exp_scenario.gui.vlayer_edit")
|
||||
for _, build_button in Elements.build_button:tracked_elements(player) do
|
||||
build_button.visible = can_edit
|
||||
end
|
||||
for _, remove_button in Elements.remove_button:tracked_elements(player) do
|
||||
remove_button.visible = can_edit
|
||||
end
|
||||
end
|
||||
|
||||
--- Container added to the left gui flow
|
||||
--- @class ExpGui_Vlayer.elements.container: ExpElement
|
||||
--- @overload fun(parent: LuaGuiElement): LuaGuiElement
|
||||
Elements.container = Gui.define("vlayer/container")
|
||||
:draw(function(_, parent)
|
||||
local container = Gui.elements.container(parent, 400)
|
||||
local stats_table = Elements.stats_table(container)
|
||||
Elements.stats_table.refresh(stats_table, Elements.stats_table.calculate_display_data())
|
||||
Elements.controls(container)
|
||||
return Gui.elements.container.get_root_element(container)
|
||||
end) --[[@as any]]
|
||||
|
||||
--- Add the element to the left flow with a toolbar button
|
||||
Gui.add_left_element(Elements.container, false)
|
||||
Gui.toolbar.create_button{
|
||||
name = "toggle_vlayer",
|
||||
left_element = Elements.container,
|
||||
sprite = "entity/solar-panel",
|
||||
tooltip = { "exp-gui_vlayer.tooltip-main" },
|
||||
visible = function(player, element)
|
||||
return Roles.player_has_permission(player, "exp_scenario.gui.vlayer")
|
||||
end
|
||||
}
|
||||
|
||||
--- Replace the one marker entity in a selected area with an interface of the type the player picked
|
||||
--- @param event EventData.on_player_selected_area
|
||||
local function on_area_selected(event)
|
||||
local player = Gui.get_player(event)
|
||||
local surface = event.surface
|
||||
local area = expand_area(event.area)
|
||||
local force = player.force --[[@as LuaForce]]
|
||||
|
||||
local interface_type = "energy" --- @type ExpScenario_Vlayer.InterfaceType
|
||||
for _, controls in Elements.controls:tracked_elements(player) do
|
||||
interface_type = Elements.controls.get_selected_type(controls)
|
||||
end
|
||||
|
||||
-- Platforms have no chests, so a combinator marks the spot once the research allows it
|
||||
local marker_name = "steel-chest"
|
||||
if config.power_on_space and surface.platform and interface_type == "energy" then
|
||||
local research = config.power_on_space_research
|
||||
if force.technologies[research.name].level < research.level then
|
||||
player.print({ "exp-gui_vlayer.message-research", research.name, research.level }, Colors.orange_red)
|
||||
return
|
||||
end
|
||||
marker_name = "constant-combinator"
|
||||
end
|
||||
|
||||
local markers = surface.find_entities_filtered{ area = area, name = marker_name, force = force }
|
||||
if #markers == 0 then
|
||||
player.print({ "exp-gui_vlayer.message-no-chest" }, Colors.orange_red)
|
||||
return
|
||||
elseif #markers > 1 then
|
||||
player.print({ "exp-gui_vlayer.message-multiple", type_captions[interface_type] }, Colors.orange_red)
|
||||
return
|
||||
end
|
||||
|
||||
local marker = assert(markers[1])
|
||||
if marker.name == "steel-chest" and not assert(marker.get_inventory(defines.inventory.chest)).is_empty() then
|
||||
player.print({ "exp-gui_vlayer.message-chest-not-empty" }, Colors.orange_red)
|
||||
return
|
||||
end
|
||||
|
||||
if #Vlayer.get_interfaces()[interface_type] >= config.interface_limit[interface_type] then
|
||||
player.print({ "exp-gui_vlayer.message-limit", type_captions[interface_type] }, Colors.orange_red)
|
||||
return
|
||||
end
|
||||
|
||||
local position = marker.position
|
||||
marker.destroy()
|
||||
|
||||
if interface_type == "energy" then
|
||||
if not Vlayer.create_energy_interface(surface, position, player) then
|
||||
player.print({ "exp-gui_vlayer.message-no-space" }, Colors.orange_red)
|
||||
return
|
||||
end
|
||||
elseif interface_type == "circuit" then
|
||||
Vlayer.create_circuit_interface(surface, position, player)
|
||||
elseif interface_type == "storage_input" then
|
||||
Vlayer.create_input_interface(surface, position, player)
|
||||
else
|
||||
Vlayer.create_output_interface(surface, position, player)
|
||||
end
|
||||
|
||||
game.print{ "exp-gui_vlayer.message-built", player.name, type_captions[interface_type], gps_string(position, surface) }
|
||||
Elements.controls.refresh_interfaces_online()
|
||||
end
|
||||
|
||||
SelectArea:on_selection(on_area_selected)
|
||||
|
||||
--- Refresh the edit buttons as the permissions of a player may have changed
|
||||
--- @param event EventData.ExpRoles.on_player_roles_changed
|
||||
local function refresh_player_permissions(event)
|
||||
Elements.controls.refresh_permissions(Gui.get_player(event))
|
||||
end
|
||||
|
||||
return {
|
||||
elements = Elements,
|
||||
events = {
|
||||
[Roles.events.on_player_roles_changed] = refresh_player_permissions,
|
||||
},
|
||||
on_nth_tick = {
|
||||
[config.update_tick_gui] = Elements.stats_table.refresh_online,
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -31,7 +31,7 @@ description-pollution-enabled=Set polution enabled state for this game.
|
||||
description-game-speed=Set or get the current game speed.
|
||||
arg-state=State to set, default is to toggle the current value.
|
||||
arg-player=Player to toggle cheat mode for.
|
||||
arg-force-friendly-fire=Force to research all technology for.
|
||||
arg-force-friendly-fire=Force to toggle friendly fire.
|
||||
arg-force-research=Force to research all technology for.
|
||||
arg-surface=Surface to toggle always day for.
|
||||
arg-amount=Amount to set, returns the current value if not given.
|
||||
@@ -150,16 +150,16 @@ arg-items-per-second=Target items per second, defaults to output of a single mac
|
||||
not-selecting=Please select an entity with a recipe.
|
||||
item-in=You need __1__ per second of [item=__2__].
|
||||
fluid-in=You need __1__ per second of [fluid=__2__].
|
||||
item-out=This will result in: __1__ [item=__2__] per second.
|
||||
fluid-out=This will result in: __1__ [fluid=__2__] per second.
|
||||
item-out=This will result in: __1__ [item=__2__] per second.
|
||||
fluid-out=This will result in: __1__ [fluid=__2__] per second.
|
||||
machine-count=And you will need __1__ machines (with the same speed as this one) for this.
|
||||
|
||||
[exp-commands_repair]
|
||||
selection-name=Repair
|
||||
description=Repairs entities on your force around you.
|
||||
# Intentional space left on the two lines below so they can be joined together.
|
||||
response-revive=__1__ entities were revived.
|
||||
response-heal=__1__ entities were healed.
|
||||
response-revive=__1__ entities were revived.
|
||||
response-heal=__1__ entities were healed.
|
||||
|
||||
[exp-commands_reports]
|
||||
description-create=Reports a player and notifies moderators
|
||||
@@ -480,6 +480,70 @@ caption-create-footer=Create task
|
||||
caption-edit-footer=Edit task
|
||||
caption-view-footer=Task details
|
||||
|
||||
[exp-gui_vlayer]
|
||||
tooltip-main=Virtual Layer
|
||||
selection-name=vlayer
|
||||
caption-stat-solar=[img=entity/solar-panel] Solar Panels
|
||||
tooltip-stat-solar=Solar panels in use out of those stored
|
||||
caption-stat-accumulator=[img=entity/accumulator] Accumulators
|
||||
tooltip-stat-accumulator=Accumulators in use out of those stored
|
||||
caption-stat-surface-area=[virtual-signal=signal-R] Remaining Surface
|
||||
tooltip-stat-surface-area=Remaining surface area, insert landfill to increase it
|
||||
caption-stat-sustained=[virtual-signal=signal-S] Sustained Production
|
||||
tooltip-stat-sustained=Power production averaged over a day, out of what every stored solar panel could give
|
||||
caption-stat-production=[virtual-signal=signal-P] Current Production
|
||||
tooltip-stat-production=Power production right now, out of the production in full daylight
|
||||
caption-stat-capacity=[virtual-signal=signal-E] Battery Charge
|
||||
tooltip-stat-capacity=Stored energy out of the accumulator capacity
|
||||
type-energy=Energy
|
||||
type-circuit=Circuit
|
||||
type-storage-input=Storage Input
|
||||
type-storage-output=Storage Output
|
||||
caption-refresh=Refresh List
|
||||
caption-view=View Interface
|
||||
caption-build=Build Interface
|
||||
caption-remove=Remove Interface
|
||||
message-located=The __1__ interface is at __2__
|
||||
message-built=__1__ built a __2__ interface at __3__
|
||||
message-removed=__1__ removed a __2__ interface at __3__
|
||||
message-no-chest=No steel chest was selected
|
||||
message-chest-not-empty=The steel chest is not empty
|
||||
message-multiple=Cannot build a __1__ interface, more than one steel chest was selected
|
||||
message-limit=Cannot build a __1__ interface, the limit has been reached
|
||||
message-no-space=Cannot build an energy interface here, there is not enough space
|
||||
message-research=You need to research [technology=__1__] to level __2__ to use the vlayer on a space platform
|
||||
|
||||
[exp-gui_warp-list]
|
||||
caption-main=Warp List [img=info]
|
||||
tooltip-main=Warp List
|
||||
tooltip-sub=Warps can only be used every __1__ seconds and when within __2__ tiles\n__3__\n__4__\n__5__\n__6__\n__7__\n__8__
|
||||
tooltip-sub-current= - __1__ This is your current warp point;
|
||||
tooltip-sub-connected= - __1__ You can travel to this warp point;
|
||||
tooltip-sub-different= - __1__ This warp is on a different network;
|
||||
tooltip-sub-cooldown= - __1__ You are currently on cooldown;
|
||||
tooltip-sub-not-available= - __1__ You are not in range of a warp point;
|
||||
tooltip-sub-bypass= - __1__ Your role allows you to travel here;
|
||||
tooltip-add=Add new warp
|
||||
tooltip-add-too-close=Cannot create warp; too close to existing warp point: __1__
|
||||
add-warning-water=Cannot create warp; too close to water, please move __1__ tiles away from the water body or landfill it
|
||||
add-warning-entities=Cannot create warp; too close to other entities, please move __1__ tiles away from the entities or remove them
|
||||
tooltip-icon=Edit warp icon
|
||||
tooltip-last-edit=Last edited by __1__ at __2__\nClick to view on map
|
||||
tooltip-confirm=Save changes
|
||||
tooltip-discard=Discard changes
|
||||
tooltip-edit=Currently being edited by: __1__
|
||||
tooltip-edit-none=Currently being edited by: Nobody
|
||||
tooltip-remove=Remove warp
|
||||
tooltip-cooldown=Please wait __1__ seconds before you can warp
|
||||
tooltip-cooldown-none=After each warp you will need to wait __1__ seconds before you can warp again
|
||||
tooltip-goto=Go to x __1__ y __2__
|
||||
tooltip-goto-bypass=Go to x __1__ y __2__, bypass mode
|
||||
tooltip-goto-bypass-different-network=Go to x __1__ y __2__, bypass mode different network
|
||||
tooltip-goto-same-warp=You are already on this warp
|
||||
tooltip-goto-different-network=This warp is on a different network, use power poles to connect it
|
||||
tooltip-goto-cooldown=You are on cooldown, wait for your cooldown to recharge
|
||||
tooltip-goto-disabled=You are not on a warp point, walk to a warp point
|
||||
|
||||
[exp_afk-kick]
|
||||
kick-message=All players were kicked because everyone was AFK.
|
||||
|
||||
@@ -490,30 +554,30 @@ reply-online=There are __1__ players online
|
||||
reply-players=There have been __1__ players on this map
|
||||
reply-dev=Cooldude2606 is a dev for this server and makes the scenario and is not a factorio dev.
|
||||
reply-softmod=A softmod is a custom scenario that runs on this server, an example is the player list.
|
||||
reply-clusterio=Clusterio is a factorio server hosting platform allowing internet enabled mods.
|
||||
reply-clusterio=Clusterio is a factorio server hosting platform allowing internet enabled mods.
|
||||
reply-blame=Blame __1__ for what just happened!
|
||||
reply-afk=You're afk? Look at __1__, that player has been afk for: __2__
|
||||
reply-evolution=Current evolution factor is __1__
|
||||
reply-magic=Fear the admin magic (ノ゚∀゚)ノ⌒・*:.。. .。.:*・゜゚・*☆
|
||||
reply-aids=≖ ‿ ≖ Fear the aids of a public server ≖ ‿ ≖
|
||||
reply-riot=(admins) ┬┴┬┴┤ᵒ_ᵒ)├┬┴┬┴ ‹ ‹\(´ω` )/››‹‹\ ( ´)/››‹‹\ ( ´ω`)/›› (rest of server)
|
||||
reply-loops=NO LOOPS; LOOPS ARE BAD; JUST NO LOOPS!!!!!; IF YOU MAKE A LOOP.... IT WILL NOT END WELL!!!!!!!
|
||||
reply-loops=NO LOOPS; LOOPS ARE BAD; JUST NO LOOPS!!!; IF YOU MAKE A LOOP… IT WILL NOT END WELL!!!
|
||||
reply-lenny=( ͡° ͜ʖ ͡°)
|
||||
reply-hodor=Hodor
|
||||
reply-popcorn-1=Heating the oil and waiting for the popping sound...
|
||||
reply-popcorn-1=Heating the oil and waiting for the popping sound…
|
||||
reply-popcorn-2=__1__ your popcorn is finished. Lean backwards and watch the drama unfold.
|
||||
reply-snaps-1=Pouring the glasses and finding the correct song book...
|
||||
reply-snaps-2=Singing a song...🎤🎶
|
||||
reply-snaps-1=Pouring the glasses and finding the correct song book…
|
||||
reply-snaps-2=Singing a song…🎤🎶
|
||||
reply-snaps-3=schkål, my friends!
|
||||
reply-cocktail-1= 🍸 Inintiating mind reading unit... 🍸
|
||||
reply-cocktail-1= 🍸 Inintiating mind reading unit… 🍸
|
||||
reply-cocktail-2= 🍸 Mixing favourite ingredients of __1__ 🍸
|
||||
reply-cocktail-3=🍸 __1__ your cocktail is done.🍸
|
||||
reply-coffee-1= ☕ Boiling the water and grinding the coffee beans... ☕
|
||||
reply-coffee-1= ☕ Boiling the water and grinding the coffee beans… ☕
|
||||
reply-coffee-2= ☕ __1__ we ran out of coffe beans! Have some tea instead. ☕
|
||||
reply-pizza-1= 🍕 Finding nearest pizza supplier... 🍕
|
||||
reply-pizza-1= 🍕 Finding nearest pizza supplier… 🍕
|
||||
reply-pizza-2= 🍕 Figuring out the favourite pizza of __1__ 🍕
|
||||
reply-pizza-3= 🍕 __1__ your pizza is here! 🍕
|
||||
reply-tea-1= ☕ Boiling the water... ☕
|
||||
reply-tea-1= ☕ Boiling the water… ☕
|
||||
reply-tea-2= ☕ __1__ your tea is done! ☕
|
||||
reply-mead-1= Filling the drinking horn
|
||||
reply-mead-2= Skål!
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
[exp-commands-authorities_role]
|
||||
deny=你沒有權限運行該項目
|
||||
deny=你沒有權限運行該項目。
|
||||
|
||||
[exp-commands-parse_role]
|
||||
lower-role=用戶組比你現有的更高
|
||||
lower-role-player=用戶有更高權限
|
||||
lower-role=用戶組比你現有的更高。
|
||||
lower-role-player=用戶有更高權限。
|
||||
|
||||
[exp-commands_admin-chat]
|
||||
description=一個只有管理員能看到的對話。
|
||||
@@ -12,31 +12,31 @@ format=[AC] __1__: __2__
|
||||
|
||||
[exp-commands_artillery]
|
||||
selection-name=火炮
|
||||
description=火炮遙控
|
||||
invalid-area=所選地區無效
|
||||
description=火炮遙控。
|
||||
invalid-area=所選地區無效。
|
||||
|
||||
[exp-commands_bot-queue]
|
||||
description=取得或更改建設隊列數量。
|
||||
arg-amount=建設隊列數量
|
||||
arg-amount=建設隊列數量。
|
||||
get=建設隊列為 __1__ 個成功嘗試,和 __2__ 個嘗試。
|
||||
set=__1__ 把建設隊列改成 __2__ 個成功嘗試,和 __3__ 個嘗試。
|
||||
|
||||
[exp-commands_cheat]
|
||||
description-cheat-mode=為你或其他玩家切換作弊模式。
|
||||
description-always-day=啟用永久白天
|
||||
description-friendly-fire=啟用友方傷害
|
||||
description-research-all=啟用所有科技
|
||||
description-clear-pollution=清除污染
|
||||
description-pollution-enabled=啟用污染
|
||||
description-game-speed=設定遊戲速度
|
||||
arg-state=狀態
|
||||
arg-player=用戶
|
||||
arg-force-friendly-fire=勢力
|
||||
arg-force-research=勢力
|
||||
arg-surface=位面
|
||||
arg-amount=數量
|
||||
description-always-day=啟用永久白天。
|
||||
description-friendly-fire=啟用友方傷害。
|
||||
description-research-all=啟用所有科技。
|
||||
description-clear-pollution=清除污染。
|
||||
description-pollution-enabled=啟用污染。
|
||||
description-game-speed=設定遊戲速度。
|
||||
arg-state=要設定的狀態,預設是切換目前值。
|
||||
arg-player=要為其切換作弊模式的玩家。
|
||||
arg-force-friendly-fire=為勢力切換友方傷害。
|
||||
arg-force-research=為勢力研究所有科技。
|
||||
arg-surface=為位面切換永久白晝。
|
||||
arg-amount=要設定的數量,如果未指定,則傳回目前值。
|
||||
cheat-mode=作弊模式現在為 __1__
|
||||
always-day=__1__ 把在 __2__ 的位面的永久白天設置為 __3__ 。
|
||||
always-day=__1__ 把在 __2__ 的位面的永久白晝設置為 __3__ 。
|
||||
friendly-fire=__1__ 已為在 __2__ 的勢力設定成 __3__ 。
|
||||
research-all=__1__ 已為在 __2__ 的勢力啟用所有科技 。
|
||||
clear-pollution=__1__ 已為在 __2__ 的位面清除所有污染 。
|
||||
@@ -46,15 +46,15 @@ game-speed-get=現在遊戲速度為 __1__ 。
|
||||
|
||||
[exp-commands_clear-inventory]
|
||||
description=清除用戶物品。
|
||||
arg-player=用戶
|
||||
arg-player=要清除其物品欄的用戶。
|
||||
|
||||
[exp-commands_connect]
|
||||
description=連接到另一服務器
|
||||
description-player=讓其他用戶連接到另一服務器
|
||||
description-all=將所有玩家連接到另一台服務器
|
||||
arg-player=連接到別的服的用戶
|
||||
arg-server=輸入為地址 / 名稱
|
||||
arg-is-address=輸入為地址
|
||||
description=連接到另一服務器。
|
||||
description-player=讓其他用戶連接到另一服務器。
|
||||
description-all=將所有玩家連接到另一台服務器。
|
||||
arg-player=連接到別的服務器的用戶。
|
||||
arg-server=輸入為地址或名稱。
|
||||
arg-is-address=輸入應該為地址。
|
||||
too-many-matching=該服務器名稱有多過一個結果: __1__
|
||||
wrong-version=該服務器版本不同: __1__
|
||||
same-server=你已連接該服務器: __1__
|
||||
@@ -65,15 +65,15 @@ none-matching=沒找到服務器。
|
||||
description=打開偵錯介面。
|
||||
|
||||
[exp-commands_enemy]
|
||||
description-kill=僅移除蟲子
|
||||
description-remove=移除蟲子及停止產生
|
||||
description-kill=僅移除蟲單位。
|
||||
description-remove=移除蟲單位及停止生產器。
|
||||
arg-surface=位面
|
||||
|
||||
[exp-commands_home]
|
||||
description-home=傳送回家
|
||||
description-set=設定目前位置為家
|
||||
description-get=取得家的位置
|
||||
description-return=傳送回上一個位置
|
||||
description-home=傳送回家。
|
||||
description-set=設定目前位置為家。
|
||||
description-get=取得家的位置。
|
||||
description-return=傳送回上一個位置。
|
||||
no-home=你在 __1__ 上還沒設回程傳送點。
|
||||
no-return=你還沒在 __1__ 上使用過回程。
|
||||
home-set=你的回程傳送點為 __1__ 上, x: __2__ y: __3__
|
||||
@@ -84,7 +84,7 @@ home-get=你的回程傳送點在 __1__ 上, x: __2__ y: __3__
|
||||
description=把用戶送監而禁止其行動。
|
||||
arg-player=用戶
|
||||
arg-reason=原因
|
||||
jailed=__1__ 已被 __2__ ,因 __3__ 而被禁止行動。
|
||||
jailed=__1__ 已被 __2__ ,因 __3__ 而被禁止行動
|
||||
already-jailed=__1__ 已被禁止行動。
|
||||
|
||||
[exp-commands_unjail]
|
||||
@@ -101,18 +101,18 @@ lower-role=用戶組比你現有的更高
|
||||
|
||||
[exp-commands_lawnmower]
|
||||
selection-name=割草機
|
||||
description=清理屍體、裝飾和核洞
|
||||
description=清理屍體、裝飾和核彈洞。
|
||||
arg-range=半徑
|
||||
complete=__1__ 格已完成。
|
||||
|
||||
[exp-commands_locate]
|
||||
description=在地圖上查找用戶
|
||||
description=在地圖上查找用戶的最後位置。
|
||||
arg-player=用戶
|
||||
arg-remote=若在使用地圖查看模式
|
||||
arg-remote=若為 true,則開啟在玩家遠端視圖的位置。
|
||||
response=__1__ 的最後地點是 [gps=__2__,__3__]
|
||||
|
||||
[exp-commands_me]
|
||||
description=在聊天中發送操作訊息
|
||||
description=在聊天中發送操作訊息。
|
||||
arg-action=你想做的動作。
|
||||
response=* __1__ __2__ *
|
||||
|
||||
@@ -121,17 +121,19 @@ description-entity=啟用建築保護
|
||||
description-area=啟用區域保護
|
||||
enter-entity=現在進入建築保護,選擇一個建築來保護,按住 shift 來選擇則可取消。
|
||||
enter-area=現在進入區域保護,選擇一個區域來保護,按住 shift 來選擇則可取消。
|
||||
exit-entity=已進入建築保護
|
||||
exit-area=已進入區域選擇
|
||||
exit-entity=已進入建築保護。
|
||||
exit-area=已進入區域選擇。
|
||||
protected-entities=__1__ 個建築現已受保護。
|
||||
unprotected-entities=__1__ 個建築現不受保護。
|
||||
already-protected=本地區已受保護。
|
||||
protected-area=本地區現已受保護。
|
||||
unprotected-area=本地區現不受保護。
|
||||
repeat-offence=__1__ 在 [gps=__3__,__4__] 拆除了 __2__
|
||||
enter-entity-selection = Entered entity selection, select entites to protect, hold shift to remove protection.
|
||||
enter-area-selection = Entered area selection, select areas to protect, hold shift to remove protection.
|
||||
|
||||
[exp-commands_tag-protection]
|
||||
description=切換管理員標記模式,新標記只能由管理員編輯
|
||||
description=切換管理員標記模式,新標記只能由管理員編輯。
|
||||
exit=你已離開管理員地圖標記模式,所有新地圖標記將不受保護。
|
||||
enter=你已進入管理員地圖標記模式,所有新地圖標記將受保護。
|
||||
create=你放了一個管理員地圖標記。
|
||||
@@ -153,6 +155,7 @@ fluid-in=你每秒需要 __1__ 來做 [fluid=__2__]。
|
||||
item-out=結果: __1__ [item=__2__] 每秒。
|
||||
fluid-out=結果: __1__ [fluid=__2__] 每秒。
|
||||
machines=你需要 __1__ 部同樣的機器。
|
||||
machine-count = And you will need __1__ machines (with the same speed as this one) for this.
|
||||
|
||||
[exp-commands_repair]
|
||||
selection-name=維修
|
||||
@@ -172,11 +175,21 @@ arg-player-clear=用戶
|
||||
arg-reason=原因
|
||||
arg-from-player=用戶
|
||||
player-immune=用戶不能被舉報
|
||||
self-report=你不能舉報自己
|
||||
self-report=你不能舉報自己。
|
||||
response=__1__ 因 __2__ 被舉報了。
|
||||
response-admin=__1__ 因 __3__ 被 __2__ 舉報了。
|
||||
already-reported=你已經舉報過該用戶了,你可以讓管理員清除報告來重寫。
|
||||
not-reported=該用戶沒有被舉報的紀錄。
|
||||
not-reported-by=該用戶沒有被 __1__ 舉報的紀錄。
|
||||
reports-title==該用戶現在的被舉報紀錄:
|
||||
player-title=__1__ 有 __2__ 項被舉報的紀錄:
|
||||
list-element=__1__: __2__
|
||||
removed-all=__1__ 被舉報的所有紀錄已被 __2__ 清除。
|
||||
removed=__1__ 被舉報的一個紀錄已被 __2__ 清除。
|
||||
|
||||
[exp-commands_roles]
|
||||
description-assign=為用戶指配用戶組
|
||||
description-unassign=為用戶取消指配用戶組
|
||||
description-assign=為用戶指配用戶組。
|
||||
description-unassign=為用戶取消指配用戶組。
|
||||
description-get=顯示所有用戶組
|
||||
arg-player-assign=指配
|
||||
arg-player-unassign=取消指配
|
||||
@@ -199,16 +212,16 @@ title=有 [item=__1__] 的用戶:
|
||||
result=\n__1__) __2__ 有 __3__ 個。 (__4__)
|
||||
|
||||
[exp-commands_spectate]
|
||||
description-spectate=切換旁觀者模式
|
||||
description-follow=開始在旁觀者模式中關注玩家
|
||||
description-spectate=切換旁觀者模式。
|
||||
description-follow=開始在旁觀者模式中關注玩家。
|
||||
arg-player=用戶
|
||||
follow-self=你不能追蹤自己
|
||||
follow-self=你不能追蹤自己。
|
||||
|
||||
[exp-commands_surface]
|
||||
selection-name=位面
|
||||
description-items=清除地面上的物品
|
||||
description-blueprints=清除藍圖
|
||||
description-blueprints-surface=清除藍圖
|
||||
description-items=清除地面上的物品。
|
||||
description-blueprints=清除藍圖。
|
||||
description-blueprints-surface=清除本位面上的藍圖。
|
||||
arg-surface=位面
|
||||
items=__1__ 清除了所有在 __2__ 中掉地上的東西。
|
||||
blueprints=__1__ 清除了所有在 __2__ 中在地上的藍圖。
|
||||
@@ -225,9 +238,9 @@ response=__1__ 把 __2__ 個火車設置為自動模式。
|
||||
description-teleport=將一名玩家傳送到另一名玩家。
|
||||
description-bring=將一名玩家傳送到你身邊。
|
||||
description-goto=將你傳送到玩家身邊。
|
||||
description-spawn=傳送到出生點。
|
||||
description-spawn=傳送到出生點
|
||||
arg-player-teleport=傳送的玩家,若沒有目標,你會被傳送到這。
|
||||
arg-player-from=傳送的玩家
|
||||
arg-player-from=傳送的玩家。
|
||||
arg-player-to=傳送的玩家目標
|
||||
unavailable=沒找到空間進行傳送
|
||||
same-player=沒辦法傳送到自己
|
||||
@@ -379,6 +392,7 @@ data-statistics=數據
|
||||
data-required=需要
|
||||
data-misc=雜項
|
||||
data-format=__1____2__
|
||||
welcome-title = Welcome to __1__
|
||||
|
||||
[exp-gui_research-milestones]
|
||||
tooltip-main=研究介面
|
||||
@@ -410,7 +424,7 @@ data-caption-fastest-launch=最快發射
|
||||
data-tooltip-fastest-launch=最快發射時間
|
||||
data-caption-total-rockets=總發射次數
|
||||
data-tooltip-total-rockets=我方總發射次數
|
||||
value-tooltip-total-rockets=__1__% 的火箭發射都在本地圖上。
|
||||
value-tooltip-total-rockets=__1__% 的火箭發射都在這張地圖上
|
||||
data-caption-avg-launch=平均時間
|
||||
data-tooltip-avg-launch=火箭發射平均時間
|
||||
data-caption-avg-launch-n=平均時間 __1__
|
||||
@@ -453,8 +467,8 @@ tooltip-cursor-empty=游標為空
|
||||
caption-main=工作流程 [img=info]
|
||||
tooltip-main=工作流程
|
||||
tooltip-sub=需要完成的工作流程\n- 你可以用富文本來加上圖片 [img=utility/not_enough_repair_packs_icon] 或 [color=blue] 顏色[/color]。
|
||||
caption-no-tasks=沒有工作流程
|
||||
tooltip-no-tasks=按加號加入工作流程
|
||||
caption-no-tasks=沒有工作流程!
|
||||
tooltip-no-tasks=按加號加入工作流程!
|
||||
tooltip-last-edit=最後由 __1__ 在 __2__ 修改
|
||||
tooltip-close=關閉工作流程
|
||||
tooltip-new=加入工作流程
|
||||
@@ -470,41 +484,106 @@ tooltip-edit-none=現沒有被人修改
|
||||
caption-create-footer=加入工作流程
|
||||
caption-edit-footer=修改工作流程
|
||||
caption-view-footer=工作流程細節
|
||||
tooltip-confirm = Save changes (minimum of 5 characters long)
|
||||
|
||||
[exp-gui_warp-list]
|
||||
caption-main=傳送陣清單 [img=info]
|
||||
tooltip-main=傳送陣清單
|
||||
tooltip-sub=傳送陣在 __1__ 秒內只能使用一次。 亦需在 __2__ 格之內使用\n__3__\n__4__\n__5__\n__6__\n__7__\n__8__
|
||||
tooltip-sub-current= - __1__ 你目前的傳送陣;
|
||||
tooltip-sub-connected= - __1__ 你可以到本傳送陣;
|
||||
tooltip-sub-different= - __1__ 該傳送陣未連接;
|
||||
tooltip-sub-cooldown= - __1__ 傳送冷卻中;
|
||||
tooltip-sub-not-available= - __1__ 你不在傳送陣範圍;
|
||||
tooltip-sub-bypass= - __1__ 你可以傳送到這裏;
|
||||
tooltip-add=新建傳送陣
|
||||
tooltip-add-too-close=無法新建傳送陣; 太接近 __1__ 了
|
||||
add-warning-water=無法新建傳送陣; 太接近水源了, 請移動 __1__ 格又或者填平該地方
|
||||
add-warning-entities=無法新建傳送陣; 太接近其他東西, 請移動 __1__ 格又或者拆除該東西
|
||||
tooltip-icon=修改傳送陣圖案
|
||||
tooltip-last-edit=最後由 __1__ 在 __2__ 更改\n按這在地圖上看
|
||||
tooltip-confirm=儲存更改
|
||||
tooltip-discard=放棄更改
|
||||
tooltip-edit=現被 __1__ 修改中
|
||||
tooltip-edit-none=現沒有被人修改
|
||||
tooltip-remove=拆除傳送陣
|
||||
tooltip-cooldown=請等 __1__ 秒才再次傳送
|
||||
tooltip-cooldown-none=你要等 __1__ 秒才可以再次傳送
|
||||
tooltip-goto=到 X __1__ Y __2__
|
||||
tooltip-goto-bypass=到 X __1__ Y __2__, 繞行模式
|
||||
tooltip-goto-bypass-different-network=到 X __1__ Y __2__, 繞行模式 (不同網絡)
|
||||
tooltip-goto-same-warp=你已在該傳送陣
|
||||
tooltip-goto-different-network=該傳送陣未連接, 你可使用電纜連接
|
||||
tooltip-goto-cooldown=傳送冷卻中, 請等候冷卻
|
||||
tooltip-goto-disabled=你不在傳送陣, 請移至任意傳送陣
|
||||
|
||||
[exp-gui_vlayer]
|
||||
tooltip-main=Vlayer 介面
|
||||
selection-name=vlayer
|
||||
caption-stat-solar=[img=entity/solar-panel] 太陽能板
|
||||
tooltip-stat-solar=使用中的太陽能板數量 / 儲存的太陽能板數量
|
||||
caption-stat-accumulator=[img=entity/accumulator] 蓄電池
|
||||
tooltip-stat-accumulator=使用中的蓄電池數量 / 儲存的蓄電池數量
|
||||
caption-stat-surface-area=[virtual-signal=signal-R] 餘下土地
|
||||
tooltip-stat-surface-area=餘下土地。 放入堆填來增加
|
||||
caption-stat-sustained=[virtual-signal=signal-S] 持續產能
|
||||
tooltip-stat-sustained=持續電力產能
|
||||
caption-stat-production=[virtual-signal=signal-P] 現時產能
|
||||
tooltip-stat-production=現時電力產能
|
||||
caption-stat-capacity=[virtual-signal=signal-E] 電池電量
|
||||
tooltip-stat-capacity=現時電池電量 / 電池最大容量
|
||||
type-energy=電力
|
||||
type-circuit=回路
|
||||
type-storage-input=放入箱
|
||||
type-storage-output=提取箱
|
||||
caption-refresh=刷新列表
|
||||
caption-view=查看介面
|
||||
caption-build=建造介面
|
||||
caption-remove=拆除介面
|
||||
message-located=__1__ 介面在 __2__
|
||||
message-built=__1__ 在 __3__ 建造了 __2__ 介面
|
||||
message-removed=__1__ 在 __3__ 拆除了 __2__ 介面
|
||||
message-no-chest=沒檢測到鋼箱
|
||||
message-chest-not-empty=鋼箱不是空的
|
||||
message-multiple=無法建造 __1__ 介面,檢測到多個鋼箱
|
||||
message-limit=無法建造 __1__ 介面,超出最大限制
|
||||
message-no-space=無法在此建造電力介面,空間不足
|
||||
message-research=你要研究 [technology=__1__] 在 __2__ 級 才可使用太空平台 vlayer 功能。
|
||||
|
||||
[exp_afk-kick]
|
||||
kick-message=因地圖中沒有活躍玩家,所以所有人都已被請離。
|
||||
|
||||
[exp_chat-auto-reply]
|
||||
chat-reply=[Compilatron] __1__
|
||||
chat-disallowed=你沒有權限使用這個指令。
|
||||
reply-online=現在有 __1__ 人上線。
|
||||
reply-players=本地圖現在有 __1__ 人曾上線。
|
||||
reply-dev=Cooldude2606 只是本場境的開發者
|
||||
chat-disallowed=You can't use global chat commands
|
||||
reply-online=現在有 __1__ 人在線
|
||||
reply-players=這張地圖上共有__1__名用戶
|
||||
reply-dev=Cooldude2606 is a dev for this server and makes the scenario and is not a factorio dev.
|
||||
reply-softmod=這裹用了自設情境。
|
||||
reply-clusterio=Clusterio is a factorio server hosting platform allowing internet enabled mods.
|
||||
reply-blame=責怪 __1__ 吧。
|
||||
reply-afk=看看 __1__, 他已掛機 __2__ 。
|
||||
reply-evolution=現在敵人進化度為 __1__ 。
|
||||
reply-blame=責怪 __1__ 吧!
|
||||
reply-afk=看看 __1__,他的掛機時長為 __2__
|
||||
reply-evolution=現在敵人進化度為 __1__
|
||||
reply-magic=Fear the admin magic (ノ゚∀゚)ノ⌒・*:.。. .。.:*・゜゚・*☆
|
||||
reply-aids=≖ ‿ ≖ Fear the aids of a public server ≖ ‿ ≖
|
||||
reply-riot=(admins) ┬┴┬┴┤ᵒ_ᵒ)├┬┴┬┴ ‹ ‹\(´ω` )/››‹‹\ ( ´)/››‹‹\ ( ´ω`)/›› (rest of server)
|
||||
reply-loops=架設迴旋處最終後果都不好。
|
||||
reply-loops=NO LOOPS; LOOPS ARE BAD; JUST NO LOOPS!!!; IF YOU MAKE A LOOP… IT WILL NOT END WELL!!!
|
||||
reply-lenny=( ͡° ͜ʖ ͡°)
|
||||
reply-hodor=Hodor
|
||||
reply-popcorn-1=Heating the oil and waiting for the popping sound...
|
||||
reply-popcorn-1=Heating the oil and waiting for the popping sound…
|
||||
reply-popcorn-2=__1__ your popcorn is finished. Lean backwards and watch the drama unfold.
|
||||
reply-snaps-1=Pouring the glasses and finding the correct song book...
|
||||
reply-snaps-2=Singing a song...🎤🎶
|
||||
reply-snaps-1=Pouring the glasses and finding the correct song book…
|
||||
reply-snaps-2=Singing a song…🎤🎶
|
||||
reply-snaps-3=schkål, my friends!
|
||||
reply-cocktail-1= 🍸 Inintiating mind reading unit... 🍸
|
||||
reply-cocktail-1= 🍸 Inintiating mind reading unit… 🍸
|
||||
reply-cocktail-2= 🍸 Mixing favourite ingredients of __1__ 🍸
|
||||
reply-cocktail-3=🍸 __1__ your cocktail is done.🍸
|
||||
reply-coffee-1= ☕ Boiling the water and grinding the coffee beans... ☕
|
||||
reply-coffee-1= ☕ Boiling the water and grinding the coffee beans… ☕
|
||||
reply-coffee-2= ☕ __1__ we ran out of coffe beans! Have some tea instead. ☕
|
||||
reply-pizza-1= 🍕 Finding nearest pizza supplier... 🍕
|
||||
reply-pizza-1= 🍕 Finding nearest pizza supplier… 🍕
|
||||
reply-pizza-2= 🍕 Figuring out the favourite pizza of __1__ 🍕
|
||||
reply-pizza-3= 🍕 __1__ your pizza is here! 🍕
|
||||
reply-tea-1= ☕ Boiling the water... ☕
|
||||
reply-tea-1= ☕ Boiling the water… ☕
|
||||
reply-tea-2= ☕ __1__ your tea is done! ☕
|
||||
reply-mead-1= Filling the drinking horn
|
||||
reply-mead-2= Skål!
|
||||
@@ -536,3 +615,22 @@ chat-jailed=__1__ 因被多次拆除受保護物體而被禁止行動。請等
|
||||
|
||||
[exp_report-jail]
|
||||
chat-jailed=__1__ 因被多次舉報而被禁止行動。請等候管理員作出下一步處理。
|
||||
|
||||
|
||||
[exp-gui_player-list]
|
||||
main-tooltip = Player List
|
||||
open-action-bar = Options
|
||||
close-action-bar = Close Options
|
||||
reason-confirm = Confirm Reason
|
||||
reason-entry = Enter Reason
|
||||
goto-player = Goto player
|
||||
bring-player = Bring player
|
||||
report-player = Report player
|
||||
jail-player = Jail player
|
||||
kick-player = Kick player
|
||||
ban-player = Ban player
|
||||
afk-time = __1__% of total map time\nLast moved __2__ ago
|
||||
open-map = __1__ __2__\n__3__\nClick to open map
|
||||
|
||||
[exp_spectate]
|
||||
follow-label = Following __1__.\nClick here or press escape to stop following.
|
||||
@@ -1,9 +1,9 @@
|
||||
[exp-commands-authorities_role]
|
||||
deny=你沒有權限運行該項目
|
||||
deny=你沒有權限運行該項目。
|
||||
|
||||
[exp-commands-parse_role]
|
||||
lower-role=用戶組比你現有的更高
|
||||
lower-role-player=用戶有更高權限
|
||||
lower-role=用戶組比你現有的更高。
|
||||
lower-role-player=用戶有更高權限。
|
||||
|
||||
[exp-commands_admin-chat]
|
||||
description=一個只有管理員能看到的對話。
|
||||
@@ -12,31 +12,31 @@ format=[AC] __1__: __2__
|
||||
|
||||
[exp-commands_artillery]
|
||||
selection-name=火炮
|
||||
description=火炮遙控
|
||||
invalid-area=所選地區無效
|
||||
description=火炮遙控。
|
||||
invalid-area=所選地區無效。
|
||||
|
||||
[exp-commands_bot-queue]
|
||||
description=取得或更改建設隊列數量。
|
||||
arg-amount=建設隊列數量
|
||||
arg-amount=建設隊列數量。
|
||||
get=建設隊列為 __1__ 個成功嘗試,和 __2__ 個嘗試。
|
||||
set=__1__ 把建設隊列改成 __2__ 個成功嘗試,和 __3__ 個嘗試。
|
||||
|
||||
[exp-commands_cheat]
|
||||
description-cheat-mode=為你或其他玩家切換作弊模式。
|
||||
description-always-day=啟用永久白天
|
||||
description-friendly-fire=啟用友方傷害
|
||||
description-research-all=啟用所有科技
|
||||
description-clear-pollution=清除污染
|
||||
description-pollution-enabled=啟用污染
|
||||
description-game-speed=設定遊戲速度
|
||||
arg-state=狀態
|
||||
arg-player=用戶
|
||||
arg-force-friendly-fire=勢力
|
||||
arg-force-research=勢力
|
||||
arg-surface=位面
|
||||
arg-amount=數量
|
||||
description-always-day=啟用永久白天。
|
||||
description-friendly-fire=啟用友方傷害。
|
||||
description-research-all=啟用所有科技。
|
||||
description-clear-pollution=清除污染。
|
||||
description-pollution-enabled=啟用污染。
|
||||
description-game-speed=設定遊戲速度。
|
||||
arg-state=要設定的狀態,預設是切換目前值。
|
||||
arg-player=要為其切換作弊模式的玩家。
|
||||
arg-force-friendly-fire=為勢力切換友方傷害。
|
||||
arg-force-research=為勢力研究所有科技。
|
||||
arg-surface=為位面切換永久白晝。
|
||||
arg-amount=要設定的數量,如果未指定,則傳回目前值。
|
||||
cheat-mode=作弊模式現在為 __1__
|
||||
always-day=__1__ 把在 __2__ 的位面的永久白天設置為 __3__ 。
|
||||
always-day=__1__ 把在 __2__ 的位面的永久白晝設置為 __3__ 。
|
||||
friendly-fire=__1__ 已為在 __2__ 的勢力設定成 __3__ 。
|
||||
research-all=__1__ 已為在 __2__ 的勢力啟用所有科技 。
|
||||
clear-pollution=__1__ 已為在 __2__ 的位面清除所有污染 。
|
||||
@@ -46,15 +46,15 @@ game-speed-get=現在遊戲速度為 __1__ 。
|
||||
|
||||
[exp-commands_clear-inventory]
|
||||
description=清除用戶物品。
|
||||
arg-player=用戶
|
||||
arg-player=要清除其物品欄的用戶。
|
||||
|
||||
[exp-commands_connect]
|
||||
description=連接到另一服務器
|
||||
description-player=讓其他用戶連接到另一服務器
|
||||
description-all=將所有玩家連接到另一台服務器
|
||||
arg-player=連接到別的服的用戶
|
||||
arg-server=輸入為地址 / 名稱
|
||||
arg-is-address=輸入為地址
|
||||
description=連接到另一服務器。
|
||||
description-player=讓其他用戶連接到另一服務器。
|
||||
description-all=將所有玩家連接到另一台服務器。
|
||||
arg-player=連接到別的服務器的用戶。
|
||||
arg-server=輸入為地址或名稱。
|
||||
arg-is-address=輸入應該為地址。
|
||||
too-many-matching=該服務器名稱有多過一個結果: __1__
|
||||
wrong-version=該服務器版本不同: __1__
|
||||
same-server=你已連接該服務器: __1__
|
||||
@@ -65,15 +65,15 @@ none-matching=沒找到服務器。
|
||||
description=打開偵錯介面。
|
||||
|
||||
[exp-commands_enemy]
|
||||
description-kill=僅移除蟲子
|
||||
description-remove=移除蟲子及停止產生
|
||||
description-kill=僅移除蟲單位。
|
||||
description-remove=移除蟲單位及停止生產器。
|
||||
arg-surface=位面
|
||||
|
||||
[exp-commands_home]
|
||||
description-home=傳送回家
|
||||
description-set=設定目前位置為家
|
||||
description-get=取得家的位置
|
||||
description-return=傳送回上一個位置
|
||||
description-home=傳送回家。
|
||||
description-set=設定目前位置為家。
|
||||
description-get=取得家的位置。
|
||||
description-return=傳送回上一個位置。
|
||||
no-home=你在 __1__ 上還沒設回程傳送點。
|
||||
no-return=你還沒在 __1__ 上使用過回程。
|
||||
home-set=你的回程傳送點為 __1__ 上, x: __2__ y: __3__
|
||||
@@ -84,7 +84,7 @@ home-get=你的回程傳送點在 __1__ 上, x: __2__ y: __3__
|
||||
description=把用戶送監而禁止其行動。
|
||||
arg-player=用戶
|
||||
arg-reason=原因
|
||||
jailed=__1__ 已被 __2__ ,因 __3__ 而被禁止行動。
|
||||
jailed=__1__ 已被 __2__ ,因 __3__ 而被禁止行動
|
||||
already-jailed=__1__ 已被禁止行動。
|
||||
|
||||
[exp-commands_unjail]
|
||||
@@ -101,18 +101,18 @@ lower-role=用戶組比你現有的更高
|
||||
|
||||
[exp-commands_lawnmower]
|
||||
selection-name=割草機
|
||||
description=清理屍體、裝飾和核洞
|
||||
description=清理屍體、裝飾和核彈洞。
|
||||
arg-range=半徑
|
||||
complete=__1__ 格已完成。
|
||||
|
||||
[exp-commands_locate]
|
||||
description=在地圖上查找用戶
|
||||
description=在地圖上查找用戶的最後位置。
|
||||
arg-player=用戶
|
||||
arg-remote=若在使用地圖查看模式
|
||||
arg-remote=若為 true,則開啟在玩家遠端視圖的位置。
|
||||
response=__1__ 的最後地點是 [gps=__2__,__3__]
|
||||
|
||||
[exp-commands_me]
|
||||
description=在聊天中發送操作訊息
|
||||
description=在聊天中發送操作訊息。
|
||||
arg-action=你想做的動作。
|
||||
response=* __1__ __2__ *
|
||||
|
||||
@@ -121,17 +121,19 @@ description-entity=啟用建築保護
|
||||
description-area=啟用區域保護
|
||||
enter-entity=現在進入建築保護,選擇一個建築來保護,按住 shift 來選擇則可取消。
|
||||
enter-area=現在進入區域保護,選擇一個區域來保護,按住 shift 來選擇則可取消。
|
||||
exit-entity=已進入建築保護
|
||||
exit-area=已進入區域選擇
|
||||
exit-entity=已進入建築保護。
|
||||
exit-area=已進入區域選擇。
|
||||
protected-entities=__1__ 個建築現已受保護。
|
||||
unprotected-entities=__1__ 個建築現不受保護。
|
||||
already-protected=本地區已受保護。
|
||||
protected-area=本地區現已受保護。
|
||||
unprotected-area=本地區現不受保護。
|
||||
repeat-offence=__1__ 在 [gps=__3__,__4__] 拆除了 __2__
|
||||
enter-entity-selection = Entered entity selection, select entites to protect, hold shift to remove protection.
|
||||
enter-area-selection = Entered area selection, select areas to protect, hold shift to remove protection.
|
||||
|
||||
[exp-commands_tag-protection]
|
||||
description=切換管理員標記模式,新標記只能由管理員編輯
|
||||
description=切換管理員標記模式,新標記只能由管理員編輯。
|
||||
exit=你已離開管理員地圖標記模式,所有新地圖標記將不受保護。
|
||||
enter=你已進入管理員地圖標記模式,所有新地圖標記將受保護。
|
||||
create=你放了一個管理員地圖標記。
|
||||
@@ -153,6 +155,7 @@ fluid-in=你每秒需要 __1__ 來做 [fluid=__2__]。
|
||||
item-out=結果: __1__ [item=__2__] 每秒。
|
||||
fluid-out=結果: __1__ [fluid=__2__] 每秒。
|
||||
machines=你需要 __1__ 部同樣的機器。
|
||||
machine-count = And you will need __1__ machines (with the same speed as this one) for this.
|
||||
|
||||
[exp-commands_repair]
|
||||
selection-name=維修
|
||||
@@ -172,11 +175,21 @@ arg-player-clear=用戶
|
||||
arg-reason=原因
|
||||
arg-from-player=用戶
|
||||
player-immune=用戶不能被舉報
|
||||
self-report=你不能舉報自己
|
||||
self-report=你不能舉報自己。
|
||||
response=__1__ 因 __2__ 被舉報了。
|
||||
response-admin=__1__ 因 __3__ 被 __2__ 舉報了。
|
||||
already-reported=你已經舉報過該用戶了,你可以讓管理員清除報告來重寫。
|
||||
not-reported=該用戶沒有被舉報的紀錄。
|
||||
not-reported-by=該用戶沒有被 __1__ 舉報的紀錄。
|
||||
reports-title==該用戶現在的被舉報紀錄:
|
||||
player-title=__1__ 有 __2__ 項被舉報的紀錄:
|
||||
list-element=__1__: __2__
|
||||
removed-all=__1__ 被舉報的所有紀錄已被 __2__ 清除。
|
||||
removed=__1__ 被舉報的一個紀錄已被 __2__ 清除。
|
||||
|
||||
[exp-commands_roles]
|
||||
description-assign=為用戶指配用戶組
|
||||
description-unassign=為用戶取消指配用戶組
|
||||
description-assign=為用戶指配用戶組。
|
||||
description-unassign=為用戶取消指配用戶組。
|
||||
description-get=顯示所有用戶組
|
||||
arg-player-assign=指配
|
||||
arg-player-unassign=取消指配
|
||||
@@ -199,16 +212,16 @@ title=有 [item=__1__] 的用戶:
|
||||
result=\n__1__) __2__ 有 __3__ 個。 (__4__)
|
||||
|
||||
[exp-commands_spectate]
|
||||
description-spectate=切換旁觀者模式
|
||||
description-follow=開始在旁觀者模式中關注玩家
|
||||
description-spectate=切換旁觀者模式。
|
||||
description-follow=開始在旁觀者模式中關注玩家。
|
||||
arg-player=用戶
|
||||
follow-self=你不能追蹤自己
|
||||
follow-self=你不能追蹤自己。
|
||||
|
||||
[exp-commands_surface]
|
||||
selection-name=位面
|
||||
description-items=清除地面上的物品
|
||||
description-blueprints=清除藍圖
|
||||
description-blueprints-surface=清除藍圖
|
||||
description-items=清除地面上的物品。
|
||||
description-blueprints=清除藍圖。
|
||||
description-blueprints-surface=清除本位面上的藍圖。
|
||||
arg-surface=位面
|
||||
items=__1__ 清除了所有在 __2__ 中掉地上的東西。
|
||||
blueprints=__1__ 清除了所有在 __2__ 中在地上的藍圖。
|
||||
@@ -225,9 +238,9 @@ response=__1__ 把 __2__ 個火車設置為自動模式。
|
||||
description-teleport=將一名玩家傳送到另一名玩家。
|
||||
description-bring=將一名玩家傳送到你身邊。
|
||||
description-goto=將你傳送到玩家身邊。
|
||||
description-spawn=傳送到出生點。
|
||||
description-spawn=傳送到出生點
|
||||
arg-player-teleport=傳送的玩家,若沒有目標,你會被傳送到這。
|
||||
arg-player-from=傳送的玩家
|
||||
arg-player-from=傳送的玩家。
|
||||
arg-player-to=傳送的玩家目標
|
||||
unavailable=沒找到空間進行傳送
|
||||
same-player=沒辦法傳送到自己
|
||||
@@ -379,6 +392,7 @@ data-statistics=數據
|
||||
data-required=需要
|
||||
data-misc=雜項
|
||||
data-format=__1____2__
|
||||
welcome-title = Welcome to __1__
|
||||
|
||||
[exp-gui_research-milestones]
|
||||
tooltip-main=研究介面
|
||||
@@ -410,7 +424,7 @@ data-caption-fastest-launch=最快發射
|
||||
data-tooltip-fastest-launch=最快發射時間
|
||||
data-caption-total-rockets=總發射次數
|
||||
data-tooltip-total-rockets=我方總發射次數
|
||||
value-tooltip-total-rockets=__1__% 的火箭發射都在本地圖上。
|
||||
value-tooltip-total-rockets=__1__% 的火箭發射都在這張地圖上
|
||||
data-caption-avg-launch=平均時間
|
||||
data-tooltip-avg-launch=火箭發射平均時間
|
||||
data-caption-avg-launch-n=平均時間 __1__
|
||||
@@ -453,8 +467,8 @@ tooltip-cursor-empty=游標為空
|
||||
caption-main=工作流程 [img=info]
|
||||
tooltip-main=工作流程
|
||||
tooltip-sub=需要完成的工作流程\n- 你可以用富文本來加上圖片 [img=utility/not_enough_repair_packs_icon] 或 [color=blue] 顏色[/color]。
|
||||
caption-no-tasks=沒有工作流程
|
||||
tooltip-no-tasks=按加號加入工作流程
|
||||
caption-no-tasks=沒有工作流程!
|
||||
tooltip-no-tasks=按加號加入工作流程!
|
||||
tooltip-last-edit=最後由 __1__ 在 __2__ 修改
|
||||
tooltip-close=關閉工作流程
|
||||
tooltip-new=加入工作流程
|
||||
@@ -470,41 +484,106 @@ tooltip-edit-none=現沒有被人修改
|
||||
caption-create-footer=加入工作流程
|
||||
caption-edit-footer=修改工作流程
|
||||
caption-view-footer=工作流程細節
|
||||
tooltip-confirm = Save changes (minimum of 5 characters long)
|
||||
|
||||
[exp-gui_warp-list]
|
||||
caption-main=傳送陣清單 [img=info]
|
||||
tooltip-main=傳送陣清單
|
||||
tooltip-sub=傳送陣在 __1__ 秒內只能使用一次。 亦需在 __2__ 格之內使用\n__3__\n__4__\n__5__\n__6__\n__7__\n__8__
|
||||
tooltip-sub-current= - __1__ 你目前的傳送陣;
|
||||
tooltip-sub-connected= - __1__ 你可以到本傳送陣;
|
||||
tooltip-sub-different= - __1__ 該傳送陣未連接;
|
||||
tooltip-sub-cooldown= - __1__ 傳送冷卻中;
|
||||
tooltip-sub-not-available= - __1__ 你不在傳送陣範圍;
|
||||
tooltip-sub-bypass= - __1__ 你可以傳送到這裏;
|
||||
tooltip-add=新建傳送陣
|
||||
tooltip-add-too-close=無法新建傳送陣; 太接近 __1__ 了
|
||||
add-warning-water=無法新建傳送陣; 太接近水源了, 請移動 __1__ 格又或者填平該地方
|
||||
add-warning-entities=無法新建傳送陣; 太接近其他東西, 請移動 __1__ 格又或者拆除該東西
|
||||
tooltip-icon=修改傳送陣圖案
|
||||
tooltip-last-edit=最後由 __1__ 在 __2__ 更改\n按這在地圖上看
|
||||
tooltip-confirm=儲存更改
|
||||
tooltip-discard=放棄更改
|
||||
tooltip-edit=現被 __1__ 修改中
|
||||
tooltip-edit-none=現沒有被人修改
|
||||
tooltip-remove=拆除傳送陣
|
||||
tooltip-cooldown=請等 __1__ 秒才再次傳送
|
||||
tooltip-cooldown-none=你要等 __1__ 秒才可以再次傳送
|
||||
tooltip-goto=到 X __1__ Y __2__
|
||||
tooltip-goto-bypass=到 X __1__ Y __2__, 繞行模式
|
||||
tooltip-goto-bypass-different-network=到 X __1__ Y __2__, 繞行模式 (不同網絡)
|
||||
tooltip-goto-same-warp=你已在該傳送陣
|
||||
tooltip-goto-different-network=該傳送陣未連接, 你可使用電纜連接
|
||||
tooltip-goto-cooldown=傳送冷卻中, 請等候冷卻
|
||||
tooltip-goto-disabled=你不在傳送陣, 請移至任意傳送陣
|
||||
|
||||
[exp-gui_vlayer]
|
||||
tooltip-main=Vlayer 介面
|
||||
selection-name=vlayer
|
||||
caption-stat-solar=[img=entity/solar-panel] 太陽能板
|
||||
tooltip-stat-solar=使用中的太陽能板數量 / 儲存的太陽能板數量
|
||||
caption-stat-accumulator=[img=entity/accumulator] 蓄電池
|
||||
tooltip-stat-accumulator=使用中的蓄電池數量 / 儲存的蓄電池數量
|
||||
caption-stat-surface-area=[virtual-signal=signal-R] 餘下土地
|
||||
tooltip-stat-surface-area=餘下土地。 放入堆填來增加
|
||||
caption-stat-sustained=[virtual-signal=signal-S] 持續產能
|
||||
tooltip-stat-sustained=持續電力產能
|
||||
caption-stat-production=[virtual-signal=signal-P] 現時產能
|
||||
tooltip-stat-production=現時電力產能
|
||||
caption-stat-capacity=[virtual-signal=signal-E] 電池電量
|
||||
tooltip-stat-capacity=現時電池電量 / 電池最大容量
|
||||
type-energy=電力
|
||||
type-circuit=回路
|
||||
type-storage-input=放入箱
|
||||
type-storage-output=提取箱
|
||||
caption-refresh=刷新列表
|
||||
caption-view=查看介面
|
||||
caption-build=建造介面
|
||||
caption-remove=拆除介面
|
||||
message-located=__1__ 介面在 __2__
|
||||
message-built=__1__ 在 __3__ 建造了 __2__ 介面
|
||||
message-removed=__1__ 在 __3__ 拆除了 __2__ 介面
|
||||
message-no-chest=沒檢測到鋼箱
|
||||
message-chest-not-empty=鋼箱不是空的
|
||||
message-multiple=無法建造 __1__ 介面,檢測到多個鋼箱
|
||||
message-limit=無法建造 __1__ 介面,超出最大限制
|
||||
message-no-space=無法在此建造電力介面,空間不足
|
||||
message-research=你要研究 [technology=__1__] 在 __2__ 級 才可使用太空平台 vlayer 功能。
|
||||
|
||||
[exp_afk-kick]
|
||||
kick-message=因地圖中沒有活躍玩家,所以所有人都已被請離。
|
||||
|
||||
[exp_chat-auto-reply]
|
||||
chat-reply=[Compilatron] __1__
|
||||
chat-disallowed=你沒有權限使用這個指令。
|
||||
reply-online=現在有 __1__ 人上線。
|
||||
reply-players=本地圖現在有 __1__ 人曾上線。
|
||||
reply-dev=Cooldude2606 只是本場境的開發者
|
||||
chat-disallowed=You can't use global chat commands
|
||||
reply-online=現在有 __1__ 人在線
|
||||
reply-players=這張地圖上共有__1__名用戶
|
||||
reply-dev=Cooldude2606 is a dev for this server and makes the scenario and is not a factorio dev.
|
||||
reply-softmod=這裹用了自設情境。
|
||||
reply-clusterio=Clusterio is a factorio server hosting platform allowing internet enabled mods.
|
||||
reply-blame=責怪 __1__ 吧。
|
||||
reply-afk=看看 __1__, 他已掛機 __2__ 。
|
||||
reply-evolution=現在敵人進化度為 __1__ 。
|
||||
reply-blame=責怪 __1__ 吧!
|
||||
reply-afk=看看 __1__,他的掛機時長為 __2__
|
||||
reply-evolution=現在敵人進化度為 __1__
|
||||
reply-magic=Fear the admin magic (ノ゚∀゚)ノ⌒・*:.。. .。.:*・゜゚・*☆
|
||||
reply-aids=≖ ‿ ≖ Fear the aids of a public server ≖ ‿ ≖
|
||||
reply-riot=(admins) ┬┴┬┴┤ᵒ_ᵒ)├┬┴┬┴ ‹ ‹\(´ω` )/››‹‹\ ( ´)/››‹‹\ ( ´ω`)/›› (rest of server)
|
||||
reply-loops=架設迴旋處最終後果都不好。
|
||||
reply-loops=NO LOOPS; LOOPS ARE BAD; JUST NO LOOPS!!!; IF YOU MAKE A LOOP… IT WILL NOT END WELL!!!
|
||||
reply-lenny=( ͡° ͜ʖ ͡°)
|
||||
reply-hodor=Hodor
|
||||
reply-popcorn-1=Heating the oil and waiting for the popping sound...
|
||||
reply-popcorn-1=Heating the oil and waiting for the popping sound…
|
||||
reply-popcorn-2=__1__ your popcorn is finished. Lean backwards and watch the drama unfold.
|
||||
reply-snaps-1=Pouring the glasses and finding the correct song book...
|
||||
reply-snaps-2=Singing a song...🎤🎶
|
||||
reply-snaps-1=Pouring the glasses and finding the correct song book…
|
||||
reply-snaps-2=Singing a song…🎤🎶
|
||||
reply-snaps-3=schkål, my friends!
|
||||
reply-cocktail-1= 🍸 Inintiating mind reading unit... 🍸
|
||||
reply-cocktail-1= 🍸 Inintiating mind reading unit… 🍸
|
||||
reply-cocktail-2= 🍸 Mixing favourite ingredients of __1__ 🍸
|
||||
reply-cocktail-3=🍸 __1__ your cocktail is done.🍸
|
||||
reply-coffee-1= ☕ Boiling the water and grinding the coffee beans... ☕
|
||||
reply-coffee-1= ☕ Boiling the water and grinding the coffee beans… ☕
|
||||
reply-coffee-2= ☕ __1__ we ran out of coffe beans! Have some tea instead. ☕
|
||||
reply-pizza-1= 🍕 Finding nearest pizza supplier... 🍕
|
||||
reply-pizza-1= 🍕 Finding nearest pizza supplier… 🍕
|
||||
reply-pizza-2= 🍕 Figuring out the favourite pizza of __1__ 🍕
|
||||
reply-pizza-3= 🍕 __1__ your pizza is here! 🍕
|
||||
reply-tea-1= ☕ Boiling the water... ☕
|
||||
reply-tea-1= ☕ Boiling the water… ☕
|
||||
reply-tea-2= ☕ __1__ your tea is done! ☕
|
||||
reply-mead-1= Filling the drinking horn
|
||||
reply-mead-2= Skål!
|
||||
@@ -536,3 +615,22 @@ chat-jailed=__1__ 因被多次拆除受保護物體而被禁止行動。請等
|
||||
|
||||
[exp_report-jail]
|
||||
chat-jailed=__1__ 因被多次舉報而被禁止行動。請等候管理員作出下一步處理。
|
||||
|
||||
|
||||
[exp-gui_player-list]
|
||||
main-tooltip = Player List
|
||||
open-action-bar = Options
|
||||
close-action-bar = Close Options
|
||||
reason-confirm = Confirm Reason
|
||||
reason-entry = Enter Reason
|
||||
goto-player = Goto player
|
||||
bring-player = Bring player
|
||||
report-player = Report player
|
||||
jail-player = Jail player
|
||||
kick-player = Kick player
|
||||
ban-player = Ban player
|
||||
afk-time = __1__% of total map time\nLast moved __2__ ago
|
||||
open-map = __1__ __2__\n__3__\nClick to open map
|
||||
|
||||
[exp_spectate]
|
||||
follow-label = Following __1__.\nClick here or press escape to stop following.
|
||||
@@ -5,17 +5,22 @@
|
||||
"author": "Cooldude2606 <https://github.com/Cooldude2606>",
|
||||
"license": "MIT",
|
||||
"repository": "explosivegaming/ExpCluster",
|
||||
"type": "module",
|
||||
"main": "dist/node/index.js",
|
||||
"scripts": {
|
||||
"prepare": "tsc --build && webpack-cli --env production"
|
||||
"prepare": "tsc --build && webpack-cli --env production",
|
||||
"test": "tap --type-strip-only --disable-coverage --allow-empty-coverage test/*.test.js",
|
||||
"coverage": "tap --coverage-report=text test/*.test.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@clusterio/controller": "workspace:^",
|
||||
"@clusterio/lib": "workspace:^"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@clusterio/controller": "workspace:^",
|
||||
"@clusterio/lib": "workspace:^",
|
||||
"@clusterio/web_ui": "workspace:^",
|
||||
"@types/node": "catalog:",
|
||||
@@ -23,6 +28,7 @@
|
||||
"antd": "catalog:",
|
||||
"react": "catalog:",
|
||||
"react-dom": "catalog:",
|
||||
"tap": "^21.1.0",
|
||||
"typescript": "catalog:",
|
||||
"webpack": "catalog:",
|
||||
"webpack-cli": "catalog:",
|
||||
@@ -32,6 +38,8 @@
|
||||
"@expcluster/lib_commands": "workspace:^",
|
||||
"@expcluster/lib_util": "workspace:^",
|
||||
"@expcluster/lib_gui": "workspace:^",
|
||||
"@expcluster/permission-groups": "workspace:^",
|
||||
"@expcluster/roles": "workspace:^",
|
||||
"@sinclair/typebox": "catalog:"
|
||||
},
|
||||
"publishConfig": {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import * as lib from "@clusterio/lib";
|
||||
import type * as lib from "@clusterio/lib";
|
||||
|
||||
/**
|
||||
* Permissions checked by the scenario in game through exp_roles.
|
||||
@@ -7,9 +7,9 @@ import * as lib from "@clusterio/lib";
|
||||
* underscores, see module/commands/_authorities.lua. Everything else is checked
|
||||
* by name at its call site.
|
||||
*/
|
||||
type Definition = [name: string, title: string, description: string, grantByDefault?: boolean];
|
||||
type Definition<Name extends string = string> = readonly [name: Name, title: string, description: string, grantByDefault?: boolean];
|
||||
|
||||
const definitions: Definition[] = [
|
||||
const definitions = [
|
||||
["exp_scenario.bypass.deconstruction_log", "Deconstruction log bypass", "Be excluded from the deconstruction log."],
|
||||
["exp_scenario.bypass.entity_protection", "Bypass entity protection", "Remove entities that the protection filter would block."],
|
||||
["exp_scenario.bypass.nuke_protection", "Bypass nuke protection", "Use nukes without the nuke protection restrictions."],
|
||||
@@ -118,8 +118,12 @@ const definitions: Definition[] = [
|
||||
["exp_scenario.player.admin", "Factorio admin", "Be promoted to Factorio admin while holding a role with this permission."],
|
||||
["exp_scenario.player.instant_respawn", "Instant respawn", "Respawn after two seconds instead of the default delay."],
|
||||
["exp_scenario.player.spectator", "Spectator", "Remove the zoom to world noise effect, as Factorio does for spectators."],
|
||||
];
|
||||
] as const satisfies readonly Definition[];
|
||||
|
||||
for (const [name, title, description, grantByDefault] of definitions) {
|
||||
lib.definePermission({ name, title, description, grantByDefault });
|
||||
}
|
||||
/** Name of a permission defined by the scenario, added to lib.Permissions in index.ts. */
|
||||
export type ScenarioPermissionName = (typeof definitions)[number][0];
|
||||
|
||||
export const permissions = definitions.map((definition: Definition<ScenarioPermissionName>): lib.PermissionDefinition => {
|
||||
const [name, title, description, grantByDefault] = definition;
|
||||
return { name, title, description, grantByDefault };
|
||||
});
|
||||
@@ -0,0 +1,344 @@
|
||||
import type * as lib from "@clusterio/lib";
|
||||
import { RoleColor } from "@expcluster/roles";
|
||||
|
||||
/**
|
||||
* A role created by the seed, as the scenario defined it before roles moved to
|
||||
* the controller. `parent` stands in for the inheritance
|
||||
* the old config had and is flattened by the seed. The default and admin roles
|
||||
* already exist, so those entries only provide the in game properties.
|
||||
*/
|
||||
export interface SeedRole {
|
||||
name: string;
|
||||
shortHand: string;
|
||||
color: RoleColor | null;
|
||||
priority?: number;
|
||||
autoAssignHours?: number;
|
||||
blockAutoAssign?: boolean;
|
||||
/** Uses the controller's default role rather than creating one. */
|
||||
isDefault?: boolean;
|
||||
/** Uses the controller's admin role rather than creating one. */
|
||||
isAdmin?: boolean;
|
||||
/** Name of the role whose permissions are also granted, applied recursively. */
|
||||
parent?: string;
|
||||
permissions: lib.PermissionName[];
|
||||
/**
|
||||
* Name of the seed group holders are placed in by their highest role.
|
||||
* Without one the holders stay in Factorio's Default group.
|
||||
*/
|
||||
group?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* A Factorio permission group created by the seed, as the scenario defined it
|
||||
* before groups moved to the controller.
|
||||
*/
|
||||
export interface SeedGroup {
|
||||
name: string;
|
||||
/** When true the input actions are the only ones disallowed, otherwise the only ones allowed. */
|
||||
isBlacklist: boolean;
|
||||
inputActions: string[];
|
||||
}
|
||||
|
||||
export const seedRoles: SeedRole[] = [
|
||||
{
|
||||
name: "System",
|
||||
shortHand: "SYS",
|
||||
color: null,
|
||||
isAdmin: true,
|
||||
permissions: [],
|
||||
},
|
||||
{
|
||||
name: "Senior Administrator",
|
||||
group: "Admin",
|
||||
shortHand: "SAdmin",
|
||||
color: new RoleColor(233, 63, 233),
|
||||
parent: "Administrator",
|
||||
permissions: [
|
||||
"exp_scenario.command._rcon",
|
||||
"exp_scenario.command.debug",
|
||||
"exp_scenario.command.set_cheat_mode",
|
||||
"exp_scenario.command.research_all",
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "Administrator",
|
||||
group: "Admin",
|
||||
shortHand: "Admin",
|
||||
color: new RoleColor(233, 63, 233),
|
||||
parent: "Moderator",
|
||||
permissions: [
|
||||
"exp_scenario.gui.warp_list.bypass_proximity",
|
||||
"exp_scenario.gui.warp_list.bypass_cooldown",
|
||||
"exp_scenario.command.connect_all",
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "Moderator",
|
||||
group: "Admin",
|
||||
shortHand: "Mod",
|
||||
color: new RoleColor(0, 170, 0),
|
||||
parent: "Trainee",
|
||||
permissions: [
|
||||
"exp_scenario.player.instant_respawn",
|
||||
"exp_scenario.command.assign_role",
|
||||
"exp_scenario.command.unassign_role",
|
||||
"exp_scenario.command.repair",
|
||||
"exp_scenario.command.kill.always",
|
||||
"exp_scenario.command.tag_clear.always",
|
||||
"exp_scenario.command.spawn.always",
|
||||
"exp_scenario.command.clear_reports",
|
||||
"exp_scenario.command.clear_inventory",
|
||||
"exp_scenario.command.kill_enemies",
|
||||
"exp_scenario.command.remove_enemies",
|
||||
"exp_scenario.command.home",
|
||||
"exp_scenario.command.set_home",
|
||||
"exp_scenario.command.get_home",
|
||||
"exp_scenario.command.return",
|
||||
"exp_scenario.command.connect_player",
|
||||
"exp_scenario.command.set_bot_queue",
|
||||
"exp_scenario.command.set_game_speed",
|
||||
"exp_scenario.command.set_friendly_fire",
|
||||
"exp_scenario.command.set_always_day",
|
||||
"exp_scenario.command.set_pollution_enabled",
|
||||
"exp_scenario.command.clear_pollution",
|
||||
"exp_scenario.gui.rocket_info.toggle_active",
|
||||
"exp_scenario.gui.rocket_info.remote_launch",
|
||||
"exp_scenario.gui.bonus",
|
||||
"exp_scenario.decon.fast_trees",
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "Trainee",
|
||||
group: "Admin",
|
||||
shortHand: "TrMod",
|
||||
color: new RoleColor(0, 170, 0),
|
||||
parent: "Veteran",
|
||||
permissions: [
|
||||
"exp_scenario.player.admin",
|
||||
"exp_scenario.player.spectator",
|
||||
"exp_scenario.bypass.reports",
|
||||
"exp_scenario.command.admin_chat",
|
||||
"exp_scenario.command.goto",
|
||||
"exp_scenario.command.teleport",
|
||||
"exp_scenario.command.bring",
|
||||
"exp_scenario.command.get_reports",
|
||||
"exp_scenario.command.protect_entity",
|
||||
"exp_scenario.command.protect_area",
|
||||
"exp_scenario.command.protect_tag",
|
||||
"exp_scenario.command.jail",
|
||||
"exp_scenario.command.unjail",
|
||||
"exp_scenario.gui.player_list.kick",
|
||||
"exp_scenario.gui.player_list.ban",
|
||||
"exp_scenario.command.spectate",
|
||||
"exp_scenario.command.follow",
|
||||
"exp_scenario.command.search",
|
||||
"exp_scenario.command.search_online",
|
||||
"exp_scenario.command.search_amount",
|
||||
"exp_scenario.command.search_recent",
|
||||
"exp_scenario.command.clear_blueprints_surface",
|
||||
"exp_scenario.gui.playerdata",
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "Board Member",
|
||||
group: "Trusted",
|
||||
shortHand: "Board",
|
||||
color: new RoleColor(247, 246, 54),
|
||||
parent: "Sponsor",
|
||||
permissions: [
|
||||
"exp_scenario.command.goto",
|
||||
"exp_scenario.command.repair",
|
||||
"exp_scenario.command.spectate",
|
||||
"exp_scenario.command.follow",
|
||||
"exp_scenario.gui.playerdata",
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "Senior Backer",
|
||||
group: "Trusted",
|
||||
shortHand: "Backer",
|
||||
color: new RoleColor(238, 172, 44),
|
||||
parent: "Sponsor",
|
||||
permissions: [],
|
||||
},
|
||||
{
|
||||
name: "Sponsor",
|
||||
group: "Trusted",
|
||||
shortHand: "Spon",
|
||||
color: new RoleColor(238, 172, 44),
|
||||
parent: "Supporter",
|
||||
permissions: [
|
||||
"exp_scenario.bypass.reports",
|
||||
"exp_scenario.player.instant_respawn",
|
||||
"exp_scenario.gui.rocket_info.toggle_active",
|
||||
"exp_scenario.gui.rocket_info.remote_launch",
|
||||
"exp_scenario.gui.bonus",
|
||||
"exp_scenario.command.home",
|
||||
"exp_scenario.command.set_home",
|
||||
"exp_scenario.command.get_home",
|
||||
"exp_scenario.command.return",
|
||||
"exp_scenario.decon.fast_trees",
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "Supporter",
|
||||
group: "Trusted",
|
||||
shortHand: "Sup",
|
||||
color: new RoleColor(230, 99, 34),
|
||||
parent: "Veteran",
|
||||
permissions: [
|
||||
"exp_scenario.player.spectator",
|
||||
"exp_scenario.command.tag_color",
|
||||
"exp_scenario.command.jail",
|
||||
"exp_scenario.command.unjail",
|
||||
"exp_scenario.command.set_join_message",
|
||||
"exp_scenario.command.remove_join_message",
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "Partner",
|
||||
group: "Trusted",
|
||||
shortHand: "Part",
|
||||
color: new RoleColor(140, 120, 200),
|
||||
parent: "Veteran",
|
||||
permissions: [
|
||||
"exp_scenario.player.spectator",
|
||||
"exp_scenario.command.jail",
|
||||
"exp_scenario.command.unjail",
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "Veteran",
|
||||
group: "Trusted",
|
||||
shortHand: "Vet",
|
||||
color: new RoleColor(140, 120, 200),
|
||||
parent: "Member",
|
||||
autoAssignHours: 10,
|
||||
permissions: [
|
||||
"exp_scenario.chat.commands",
|
||||
"exp_scenario.command.clear_ground_items",
|
||||
"exp_scenario.command.clear_blueprints",
|
||||
"exp_scenario.command.set_trains_to_automatic",
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "Member",
|
||||
group: "Standard",
|
||||
shortHand: "Mem",
|
||||
color: new RoleColor(24, 172, 188),
|
||||
parent: "Regular",
|
||||
permissions: [
|
||||
"exp_scenario.bypass.deconstruction_log",
|
||||
"exp_scenario.gui.task_list.add",
|
||||
"exp_scenario.gui.task_list.edit",
|
||||
"exp_scenario.gui.warp_list.add",
|
||||
"exp_scenario.gui.warp_list.edit",
|
||||
"exp_scenario.gui.surveillance",
|
||||
"exp_scenario.gui.vlayer_edit",
|
||||
"exp_scenario.gui.tool",
|
||||
"exp_scenario.command.save_quickbar",
|
||||
"exp_scenario.command.vlayer_info",
|
||||
"exp_scenario.command.lawnmower",
|
||||
"exp_scenario.command.waterfill",
|
||||
"exp_scenario.command.artillery",
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "Regular",
|
||||
group: "Standard",
|
||||
shortHand: "Reg",
|
||||
color: new RoleColor(79, 155, 163),
|
||||
autoAssignHours: 3,
|
||||
permissions: [
|
||||
"exp_scenario.command.kill",
|
||||
"exp_scenario.command.rainbow",
|
||||
"exp_scenario.command.spawn",
|
||||
"exp_scenario.command.me",
|
||||
"exp_scenario.decon.standard",
|
||||
"exp_scenario.bypass.entity_protection",
|
||||
"exp_scenario.bypass.nuke_protection",
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "Jail",
|
||||
group: "Restricted",
|
||||
shortHand: "Jail",
|
||||
color: new RoleColor(50, 50, 50),
|
||||
priority: 1,
|
||||
blockAutoAssign: true,
|
||||
permissions: [],
|
||||
},
|
||||
{
|
||||
name: "Guest",
|
||||
group: "Guest",
|
||||
shortHand: "",
|
||||
color: new RoleColor(185, 187, 160),
|
||||
isDefault: true,
|
||||
permissions: [],
|
||||
},
|
||||
];
|
||||
|
||||
const adminDisallowed = [
|
||||
"add_permission_group",
|
||||
"delete_permission_group",
|
||||
"edit_permission_group",
|
||||
"import_permissions_string",
|
||||
"map_editor_action",
|
||||
"toggle_map_editor",
|
||||
"change_multiplayer_config",
|
||||
"set_heat_interface_mode",
|
||||
"set_heat_interface_temperature",
|
||||
"set_infinity_container_filter_item",
|
||||
"set_infinity_container_remove_unfiltered_items",
|
||||
"set_infinity_pipe_filter",
|
||||
];
|
||||
|
||||
const trustedDisallowed = [
|
||||
...adminDisallowed,
|
||||
"admin_action",
|
||||
];
|
||||
|
||||
const standardDisallowed = [
|
||||
...trustedDisallowed,
|
||||
"change_programmable_speaker_alert_parameters",
|
||||
"drop_item",
|
||||
"open_new_platform_button_from_rocket_silo",
|
||||
"set_rocket_silo_send_to_orbit_automated_mode",
|
||||
];
|
||||
|
||||
const guestDisallowed = [
|
||||
...standardDisallowed,
|
||||
"change_programmable_speaker_parameters",
|
||||
"change_train_stop_station",
|
||||
"remove_cables",
|
||||
"remove_train_station",
|
||||
"reset_assembling_machine",
|
||||
"rotate_entity",
|
||||
"launch_rocket",
|
||||
"cancel_research",
|
||||
"flush_opened_entity_fluid",
|
||||
"flush_opened_entity_specific_fluid",
|
||||
];
|
||||
|
||||
export const seedGroups: SeedGroup[] = [
|
||||
{ name: "Admin", isBlacklist: true, inputActions: adminDisallowed },
|
||||
{ name: "Trusted", isBlacklist: true, inputActions: trustedDisallowed },
|
||||
{ name: "Standard", isBlacklist: true, inputActions: standardDisallowed },
|
||||
{ name: "Guest", isBlacklist: true, inputActions: guestDisallowed },
|
||||
{ name: "Restricted", isBlacklist: false, inputActions: ["write_to_console"] },
|
||||
];
|
||||
|
||||
/** The permissions a seed role grants, including those of its parents. */
|
||||
export function flattenSeedPermissions(role: SeedRole, roles = seedRoles) {
|
||||
const permissions = new Set<lib.PermissionName>();
|
||||
const seen = new Set<string>();
|
||||
let current: SeedRole | undefined = role;
|
||||
while (current && !seen.has(current.name)) {
|
||||
seen.add(current.name);
|
||||
for (const permission of current.permissions) {
|
||||
permissions.add(permission);
|
||||
}
|
||||
current = roles.find(other => other.name === current!.parent);
|
||||
}
|
||||
return permissions;
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
import t from "tap";
|
||||
import * as lib from "@clusterio/lib";
|
||||
import { Controller } from "@clusterio/controller";
|
||||
import { ControllerPlugin } from "../dist/node/controller.js";
|
||||
import * as messages from "../dist/node/messages.js";
|
||||
import { seedRoles, seedGroups } from "../dist/node/seed.js";
|
||||
import * as roles from "@expcluster/roles";
|
||||
import * as groups from "@expcluster/permission-groups";
|
||||
import { ControllerPlugin as RolesPlugin } from "@expcluster/roles/dist/node/controller.js";
|
||||
import { ControllerPlugin as GroupsPlugin } from "@expcluster/permission-groups/dist/node/controller.js";
|
||||
import { GroupRecord, GroupPermissions, RoleMappingRecord } from "@expcluster/permission-groups";
|
||||
|
||||
import { plugin } from "../dist/node/index.js";
|
||||
|
||||
// Registering the plugin defines the permissions the seed grants
|
||||
lib.registerPluginPermissions([plugin]);
|
||||
|
||||
// The controller validates message classes against the link registry
|
||||
for (const Message of [messages.SeedRequest, ...roles.plugin.messages, ...groups.plugin.messages]) {
|
||||
lib.Link.register(Message);
|
||||
}
|
||||
|
||||
const logger = { child: () => logger, info: () => {}, warn: () => {}, error: () => {}, verbose: () => {} };
|
||||
|
||||
// Silence the singleton logger to avoid polluting the test output
|
||||
lib.logger.silent = true;
|
||||
t.after(() => {
|
||||
lib.logger.silent = false;
|
||||
});
|
||||
|
||||
/** Build the plugin around a real controller, which is side effect free while not started. */
|
||||
async function startPlugin(t2, { withPlugins = true } = {}) {
|
||||
const controllerConfig = new lib.ControllerConfig("controller", {
|
||||
"controller.database_directory": t2.testdir(),
|
||||
"controller.default_role_id": lib.Role.DefaultPlayerRoleId,
|
||||
});
|
||||
const controller = new Controller(logger, [], controllerConfig);
|
||||
controller.roles.set(new lib.Role(0, "Cluster Admin", "", new Set(["core.admin"])));
|
||||
controller.roles.set(new lib.Role(1, "Player", "", new Set()));
|
||||
|
||||
if (withPlugins) {
|
||||
for (const [name, Plugin] of [["exp_roles", RolesPlugin], ["exp_groups", GroupsPlugin]]) {
|
||||
const plugin = new Plugin({ name }, controller, undefined, logger);
|
||||
await plugin.init();
|
||||
}
|
||||
}
|
||||
|
||||
const plugin = new ControllerPlugin({ name: "exp_scenario" }, controller, undefined, logger);
|
||||
await plugin.init();
|
||||
return { plugin, controller };
|
||||
}
|
||||
|
||||
const byName = (datastore, name) => [...datastore.values()].find(other => other.name === name);
|
||||
|
||||
t.test("class ControllerPlugin", t2 => {
|
||||
t2.test(".handleSeedRequest() throws when the seeded plugins are missing", async t3 => {
|
||||
const { plugin } = await startPlugin(t3, { withPlugins: false });
|
||||
await t3.rejects(
|
||||
plugin.handleSeedRequest(),
|
||||
{ message: "Seeding requires the exp_roles and exp_groups plugins" },
|
||||
"the request is rejected",
|
||||
);
|
||||
});
|
||||
|
||||
t2.test(".handleSeedRequest() creates the roles and reuses them by name", async t3 => {
|
||||
const { plugin, controller } = await startPlugin(t3);
|
||||
const rolesPlugin = RolesPlugin.get(controller);
|
||||
|
||||
await plugin.handleSeedRequest();
|
||||
t3.strictSame(controller.roles.size, seedRoles.length, "every seed role exists");
|
||||
|
||||
const moderator = byName(controller.roles, "Moderator");
|
||||
t3.ok(moderator.permissions.has("exp_scenario.command.jail"), "parent permissions are flattened in");
|
||||
t3.strictSame(rolesPlugin.roleMeta.get(moderator.id).shortHand, "Mod", "the role properties match the seed");
|
||||
|
||||
await plugin.handleSeedRequest();
|
||||
t3.strictSame(controller.roles.size, seedRoles.length, "seeding again reuses the roles");
|
||||
});
|
||||
|
||||
t2.test(".handleSeedRequest() creates the groups and resets them by name", async t3 => {
|
||||
const { plugin, controller } = await startPlugin(t3);
|
||||
const groupsPlugin = GroupsPlugin.get(controller);
|
||||
|
||||
await plugin.handleSeedRequest();
|
||||
t3.strictSame(groupsPlugin.groups.size, seedGroups.length, "every seed group exists");
|
||||
|
||||
const restricted = byName(groupsPlugin.groups, "Restricted");
|
||||
t3.strictSame(restricted.permissions.isBlacklist, false, "the group only allows the listed actions");
|
||||
t3.strictSame(restricted.permissions.permissions, ["write_to_console"], "the actions match the seed");
|
||||
|
||||
const admin = byName(groupsPlugin.groups, "Admin");
|
||||
groupsPlugin.groups.set(new GroupRecord(admin.id, admin.name, new GroupPermissions(true, [])));
|
||||
await plugin.handleSeedRequest();
|
||||
t3.strictSame(groupsPlugin.groups.size, seedGroups.length, "seeding again reuses the groups");
|
||||
t3.ok(
|
||||
byName(groupsPlugin.groups, "Admin").permissions.permissions.includes("toggle_map_editor"),
|
||||
"seeding again resets the actions",
|
||||
);
|
||||
});
|
||||
|
||||
t2.test(".handleSeedRequest() maps each role onto its group by rank", async t3 => {
|
||||
const { plugin, controller } = await startPlugin(t3);
|
||||
const groupsPlugin = GroupsPlugin.get(controller);
|
||||
|
||||
await plugin.handleSeedRequest();
|
||||
const mapped = seedRoles.filter(role => role.group !== undefined);
|
||||
t3.strictSame(groupsPlugin.roleMappings.size, mapped.length, "every role with a group is mapped");
|
||||
|
||||
const mappingOf = name => [...groupsPlugin.roleMappings.values()]
|
||||
.find(mapping => mapping.roleIds.has(byName(controller.roles, name).id));
|
||||
const groupOf = name => groupsPlugin.groups.get(mappingOf(name).groupId).name;
|
||||
t3.strictSame(groupOf("Player"), "Guest", "the default role maps to the guest group");
|
||||
t3.strictSame(groupOf("Jail"), "Restricted", "jail maps to the restricted group");
|
||||
t3.ok(mappingOf("Jail").priority > mappingOf("Senior Administrator").priority, "jail outranks every role");
|
||||
t3.ok(mappingOf("Moderator").priority > mappingOf("Veteran").priority, "the role order sets the rank");
|
||||
t3.ok(mappingOf("Veteran").priority > mappingOf("Player").priority, "the default role ranks lowest");
|
||||
t3.strictSame(mappingOf("Cluster Admin"), undefined, "the admin role keeps the factorio default group");
|
||||
|
||||
const priorities = [...groupsPlugin.roleMappings.values()].map(mapping => mapping.priority);
|
||||
t3.strictSame(priorities.length, new Set(priorities).size, "priorities are unique");
|
||||
});
|
||||
|
||||
t2.test(".handleSeedRequest() reuses mappings and keeps clear of other mappings", async t3 => {
|
||||
const { plugin, controller } = await startPlugin(t3);
|
||||
const groupsPlugin = GroupsPlugin.get(controller);
|
||||
|
||||
groupsPlugin.roleMappings.set(new RoleMappingRecord(99, new Set([0, 1]), 5, 2, true));
|
||||
await plugin.handleSeedRequest();
|
||||
const first = new Map([...groupsPlugin.roleMappings.values()].map(mapping => [mapping.id, mapping.priority]));
|
||||
|
||||
await plugin.handleSeedRequest();
|
||||
const second = new Map([...groupsPlugin.roleMappings.values()].map(mapping => [mapping.id, mapping.priority]));
|
||||
t3.strictSame(second, first, "seeding again reuses the mappings");
|
||||
t3.strictSame(groupsPlugin.roleMappings.get(99).priority, 2, "other mappings are left alone");
|
||||
t3.notOk([...first.values()].filter(priority => priority === 2).length > 1, "seed priorities skip taken ones");
|
||||
});
|
||||
|
||||
t2.end();
|
||||
});
|
||||
@@ -0,0 +1,86 @@
|
||||
import t from "tap";
|
||||
import * as lib from "@clusterio/lib";
|
||||
import { seedRoles, seedGroups, flattenSeedPermissions } from "../dist/node/seed.js";
|
||||
|
||||
import { plugin } from "../dist/node/index.js";
|
||||
|
||||
// Registering the plugin defines the permissions the seed grants
|
||||
lib.registerPluginPermissions([plugin]);
|
||||
|
||||
t.test("seedRoles[] grant only defined permissions", t2 => {
|
||||
for (const role of seedRoles) {
|
||||
for (const permission of role.permissions) {
|
||||
t2.ok(lib.permissions.has(permission), `${role.name} grants defined permission ${permission}`);
|
||||
}
|
||||
}
|
||||
t2.end();
|
||||
});
|
||||
|
||||
t.test("seedRoles[] are unique with one default and one admin", t2 => {
|
||||
const names = seedRoles.map(role => role.name);
|
||||
t2.strictSame(names.length, new Set(names).size, "names are unique");
|
||||
t2.strictSame(seedRoles.filter(role => role.isDefault).length, 1, "one default role");
|
||||
t2.strictSame(seedRoles.filter(role => role.isAdmin).length, 1, "one admin role");
|
||||
t2.end();
|
||||
});
|
||||
|
||||
t.test("seedRoles[] are placed in defined groups", t2 => {
|
||||
const groupNames = new Set(seedGroups.map(group => group.name));
|
||||
for (const role of seedRoles) {
|
||||
if (role.group !== undefined) {
|
||||
t2.ok(groupNames.has(role.group), `${role.name} is placed in defined group ${role.group}`);
|
||||
}
|
||||
}
|
||||
t2.end();
|
||||
});
|
||||
|
||||
t.test("seedGroups[] are unique", t2 => {
|
||||
const names = seedGroups.map(group => group.name);
|
||||
t2.strictSame(names.length, new Set(names).size, "names are unique");
|
||||
for (const group of seedGroups) {
|
||||
t2.strictSame(
|
||||
group.inputActions.length,
|
||||
new Set(group.inputActions).size,
|
||||
`${group.name} lists each input action once`,
|
||||
);
|
||||
}
|
||||
t2.end();
|
||||
});
|
||||
|
||||
t.test("flattenSeedPermissions() inherits permissions from parent roles", t2 => {
|
||||
const byName = new Map(seedRoles.map(role => [role.name, role]));
|
||||
for (const role of seedRoles) {
|
||||
if (role.parent === undefined) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const parent = byName.get(role.parent);
|
||||
t2.ok(parent, `${role.name} has parent ${role.parent}`);
|
||||
|
||||
const flattened = flattenSeedPermissions(role);
|
||||
for (const permission of flattenSeedPermissions(parent)) {
|
||||
t2.ok(flattened.has(permission), `${role.name} inherits ${permission}`);
|
||||
}
|
||||
}
|
||||
t2.end();
|
||||
});
|
||||
|
||||
t.test("flattenSeedPermissions() does not inherit permissions when parent is undefined", t2 => {
|
||||
for (const role of seedRoles) {
|
||||
if (role.parent !== undefined) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const flattened = flattenSeedPermissions(role);
|
||||
for (const permission of role.permissions) {
|
||||
t2.ok(flattened.has(permission), `${role.name} contains ${permission}`);
|
||||
}
|
||||
|
||||
t2.equal(
|
||||
flattened.size,
|
||||
role.permissions.length,
|
||||
`${role.name} has no inherited permissions`,
|
||||
);
|
||||
}
|
||||
t2.end();
|
||||
});
|
||||
@@ -1,4 +1,4 @@
|
||||
{
|
||||
"extends": "../tsconfig.browser.json",
|
||||
"include": [ "web/**/*.tsx", "web/**/*.ts", "messages.ts", "package.json" ],
|
||||
"include": [ "web/**/*.tsx", "web/**/*.ts", "index.ts", "messages.ts", "permissions.ts", "package.json" ],
|
||||
}
|
||||
@@ -1,5 +1,9 @@
|
||||
{
|
||||
"extends": "../tsconfig.node.json",
|
||||
"references": [
|
||||
{ "path": "../exp_groups/tsconfig.node.json" },
|
||||
{ "path": "../exp_roles/tsconfig.node.json" },
|
||||
],
|
||||
"include": ["./**/*.ts"],
|
||||
"exclude": ["test/*", "./dist/*"],
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
import React, { useContext, useState } from "react";
|
||||
import { Button, Popconfirm } from "antd";
|
||||
|
||||
import { ControlContext, SectionHeader, useAccount, notifyErrorHandler } from "@clusterio/web_ui";
|
||||
|
||||
import { SeedRequest } from "../../messages.js";
|
||||
|
||||
/** Button on the roles page which creates the roles and permission groups the scenario shipped with. */
|
||||
export default function Seed() {
|
||||
const control = useContext(ControlContext);
|
||||
const account = useAccount();
|
||||
const [seeding, setSeeding] = useState(false);
|
||||
|
||||
if (!account.hasPermission("exp_scenario.seed")) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return <SectionHeader
|
||||
title="ExpGaming Roles"
|
||||
extra={<Popconfirm
|
||||
title="Create the ExpGaming roles and permission groups?"
|
||||
description="Roles which already exist by name only gain permissions, groups are reset to the defaults."
|
||||
onConfirm={() => {
|
||||
setSeeding(true);
|
||||
control.send(new SeedRequest())
|
||||
.catch(notifyErrorHandler("Error seeding roles and groups"))
|
||||
.finally(() => setSeeding(false));
|
||||
}}
|
||||
>
|
||||
<Button loading={seeding}>Seed roles and groups</Button>
|
||||
</Popconfirm>}
|
||||
/>;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
import { BaseWebPlugin } from "@clusterio/web_ui";
|
||||
|
||||
import Seed from "./components/Seed";
|
||||
|
||||
export class WebPlugin extends BaseWebPlugin {
|
||||
async init() {
|
||||
this.componentExtra = {
|
||||
RolesPage: Seed,
|
||||
};
|
||||
}
|
||||
}
|
||||
File renamed without changes.
Reference in new issue
Block a user