Move the virtual layer into exp_scenario (#463)

The virtual layer was a legacy control module and a legacy gui built on
the legacy event system. The control module moves to
exp_scenario/module/control/vlayer.lua in the event_handler shape, with the
data typed and the allowed item table built locally rather than by
rewriting the config. The gui moves to exp_scenario/module/gui/vlayer.lua
in the shape of the other scenario guis: statistics as label and bar
defines refreshed from display data computed once, and the interface
controls as a define which owns its dropdowns.

Api changes while moving: interfaces are removed by entity rather than by
searching a position, the dead circuit wiring parameter is gone since
connect_neighbour no longer exists, and remove_item now takes only the
unallocated amount out of storage and counts that production back out of
the total, which the legacy module got wrong.

The locale moves to [exp-gui_vlayer] in en, zh-CN and zh-TW and the legacy
[vlayer] sections, modules and file loader entries are removed.

Co-authored-by: Cooldude2606 <25043174+Cooldude2606@users.noreply.github.com>
This commit is contained in:
BastiaanandCooldude2606 authored and GitHub committed 2026-09-26 22:46:08 +01:00
1 parent a2ce3ded81
commit 862fe49b60
14 files changed
+1310 -1484

No files matched your search

+2 -2
View File
@@ -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
+2
View File
@@ -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,6 +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"))
+673
View File
@@ -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
+3 -3
View File
@@ -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
+531
View File
@@ -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,
}
}
+33
View File
@@ -490,6 +490,39 @@ 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
+33
View File
@@ -517,6 +517,39 @@ 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=因地圖中沒有活躍玩家,所以所有人都已被請離。
+33
View File
@@ -517,6 +517,39 @@ 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=因地圖中沒有活躍玩家,所以所有人都已被請離。