From 161a41bb83aec86f5d1dece035a88f4cdefe2739 Mon Sep 17 00:00:00 2001 From: PHIDIAS Date: Fri, 6 Sep 2024 02:55:35 +0900 Subject: [PATCH 01/10] Update vlayer.lua --- modules/control/vlayer.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/control/vlayer.lua b/modules/control/vlayer.lua index 8fb1d45b3a..6669df815c 100644 --- a/modules/control/vlayer.lua +++ b/modules/control/vlayer.lua @@ -441,6 +441,7 @@ function vlayer.get_statistics() used_surface_area = vlayer_data.properties.used_surface_area, remaining_surface_area = vlayer_data.properties.total_surface_area - vlayer_data.properties.used_surface_area, production_multiplier = get_production_multiplier(), + energy_max = vlayer_data.properties.production * mega, energy_production = vlayer_data.properties.production * mega * get_production_multiplier(), energy_sustained = vlayer_data.properties.production * mega * get_sustained_multiplier(), energy_capacity = vlayer_data.properties.capacity * mega, From 539afa9c02f95625cbcc63e18bacc0dd0116d052 Mon Sep 17 00:00:00 2001 From: PHIDIAS Date: Fri, 6 Sep 2024 02:56:11 +0900 Subject: [PATCH 02/10] Update vlayer.lua --- modules/gui/vlayer.lua | 172 ++++++++++++++++++++--------------------- 1 file changed, 84 insertions(+), 88 deletions(-) diff --git a/modules/gui/vlayer.lua b/modules/gui/vlayer.lua index 6ac8baf9c8..375a0ff472 100644 --- a/modules/gui/vlayer.lua +++ b/modules/gui/vlayer.lua @@ -140,7 +140,7 @@ Gui.element{ type = 'label', name = 'vlayer_display_item_solar_name', caption = {'vlayer.display-item-solar'}, - style = 'heading_1_label' + style = 'heading_2_label' }:style{ width = 200 } @@ -150,9 +150,9 @@ Gui.element{ type = 'label', name = 'vlayer_display_item_solar_count', caption = '0', - style = 'heading_1_label' + style = 'heading_2_label' }:style{ - width = 120 + width = 200 } --- Display label for the number of accumulators @@ -162,7 +162,7 @@ Gui.element{ type = 'label', name = 'vlayer_display_item_accumulator_name', caption = {'vlayer.display-item-accumulator'}, - style = 'heading_1_label' + style = 'heading_2_label' }:style{ width = 200 } @@ -172,32 +172,32 @@ Gui.element{ type = 'label', name = 'vlayer_display_item_accumulator_count', caption = '0', - style = 'heading_1_label' + style = 'heading_2_label' }:style{ - width = 120 + width = 200 } ---- Display label for the current energy production --- @element vlayer_gui_display_signal_production_name -local vlayer_gui_display_signal_production_name = +--- Display label for the remaining surface area +-- @element vlayer_gui_display_signal_remaining_surface_area_name +local vlayer_gui_display_signal_remaining_surface_area_name = Gui.element{ type = 'label', - name = 'vlayer_display_signal_peak_name', - caption = {'vlayer.display-current-production'}, - tooltip = {'vlayer.display-current-production-tooltip'}, - style = 'heading_1_label' + name = 'vlayer_display_signal_remaining_surface_area_name', + caption = {'vlayer.display-remaining-surface-area'}, + tooltip = {'vlayer.display-remaining-surface-area-tooltip'}, + style = 'heading_2_label' }:style{ width = 200 } -local vlayer_gui_display_signal_production_count = +local vlayer_gui_display_signal_remaining_surface_area_count = Gui.element{ type = 'label', - name = 'vlayer_display_signal_peak_solar_count', + name = 'vlayer_display_signal_remaining_surface_area_count', caption = '0', - style = 'heading_1_label' + style = 'heading_2_label' }:style{ - width = 120 + width = 200 } --- Display label for the sustained energy production @@ -208,7 +208,7 @@ Gui.element{ name = 'vlayer_display_signal_sustained_name', caption = {'vlayer.display-sustained-production'}, tooltip = {'vlayer.display-sustained-production-tooltip'}, - style = 'heading_1_label' + style = 'heading_2_label' }:style{ width = 200 } @@ -218,78 +218,59 @@ Gui.element{ type = 'label', name = 'vlayer_display_signal_sustained_count', caption = '0', - style = 'heading_1_label' + style = 'heading_2_label' }:style{ - width = 120 + width = 200 } ---- Display label for the sustained energy capacity --- @element vlayer_gui_display_signal_capacity_name -local vlayer_gui_display_signal_capacity_name = +--- Display label for the current energy production +-- @element vlayer_gui_display_signal_production_name +local vlayer_gui_display_signal_production_name = Gui.element{ type = 'label', - name = 'vlayer_display_signal_max_name', - caption = {'vlayer.display-max-capacity'}, - tooltip = {'vlayer.display-max-capacity-tooltip'}, - style = 'heading_1_label' + name = 'vlayer_display_signal_production_name', + caption = {'vlayer.display-current-production'}, + tooltip = {'vlayer.display-current-production-tooltip'}, + style = 'heading_2_label' }:style{ width = 200 } -local vlayer_gui_display_signal_capacity_count = +local vlayer_gui_display_signal_production_count = Gui.element{ - type = 'label', - name = 'vlayer_display_signal_max_count', - caption = '0', - style = 'heading_1_label' + type = 'progressbar', + name = 'vlayer_display_signal_production_count', + caption = '', + value = 0, + style = 'electric_satisfaction_statistics_progressbar' }:style{ - width = 120 + width = 200, + font = 'heading-3' } ---- Display label for the current energy in storage --- @element vlayer_gui_display_signal_current_name -local vlayer_gui_display_signal_current_name = +--- Display label for the sustained energy capacity +-- @element vlayer_gui_display_signal_capacity_name +local vlayer_gui_display_signal_capacity_name = Gui.element{ type = 'label', - name = 'vlayer_display_signal_current_name', + name = 'vlayer_display_signal_capacity_name', caption = {'vlayer.display-current-capacity'}, tooltip = {'vlayer.display-current-capacity-tooltip'}, - style = 'heading_1_label' -}:style{ - width = 200 -} - -local vlayer_gui_display_signal_current_count = -Gui.element{ - type = 'label', - name = 'vlayer_display_signal_current_count', - caption = '0', - style = 'heading_1_label' -}:style{ - width = 120 -} - ---- Display label for the remaining surface area --- @element vlayer_gui_display_signal_remaining_surface_area_name -local vlayer_gui_display_signal_remaining_surface_area_name = -Gui.element{ - type = 'label', - name = 'vlayer_display_signal_remaining_surface_area_name', - caption = {'vlayer.display-remaining-surface-area'}, - tooltip = {'vlayer.display-remaining-surface-area-tooltip'}, - style = 'heading_1_label' + style = 'heading_2_label' }:style{ width = 200 } -local vlayer_gui_display_signal_remaining_surface_area_count = +local vlayer_gui_display_signal_capacity_count = Gui.element{ - type = 'label', - name = 'vlayer_display_signal_remaining_surface_area_count', - caption = '0', - style = 'heading_1_label' + type = 'progressbar', + name = 'vlayer_display_signal_capacity_count', + caption = '', + value = 0, + style = 'electric_satisfaction_statistics_progressbar' }:style{ - width = 120 + width = 200, + font = 'heading-3' } --- A vertical flow containing all the displays labels and their counts @@ -297,7 +278,7 @@ Gui.element{ local vlayer_display_set = Gui.element(function(_, parent, name) local vlayer_set = parent.add{type='flow', direction='vertical', name=name} - local disp = Gui.scroll_table(vlayer_set, 320, 2, 'disp') + local disp = Gui.scroll_table(vlayer_set, 400, 2, 'disp') vlayer_gui_display_item_solar_name(disp) vlayer_gui_display_item_solar_count(disp) @@ -305,14 +286,12 @@ Gui.element(function(_, parent, name) vlayer_gui_display_item_accumulator_count(disp) vlayer_gui_display_signal_remaining_surface_area_name(disp) vlayer_gui_display_signal_remaining_surface_area_count(disp) - vlayer_gui_display_signal_production_name(disp) - vlayer_gui_display_signal_production_count(disp) vlayer_gui_display_signal_sustained_name(disp) vlayer_gui_display_signal_sustained_count(disp) + vlayer_gui_display_signal_production_name(disp) + vlayer_gui_display_signal_production_count(disp) vlayer_gui_display_signal_capacity_name(disp) vlayer_gui_display_signal_capacity_count(disp) - vlayer_gui_display_signal_current_name(disp) - vlayer_gui_display_signal_current_count(disp) return vlayer_set end) @@ -343,7 +322,7 @@ Gui.element{ items = {{'vlayer.control-type-energy'}, {'vlayer.control-type-circuit'}, {'vlayer.control-type-storage-input'}, {'vlayer.control-type-storage-output'}}, selected_index = 1 }:style{ - width = 160 + width = 200 }:on_selection_changed(function(player, _, _) vlayer_gui_list_refresh(player) end) @@ -355,7 +334,7 @@ Gui.element{ type = 'drop-down', name = Gui.unique_static_name }:style{ - width = 160 + width = 200 } --- A button to refresh the remove list @@ -366,7 +345,7 @@ Gui.element{ name = Gui.unique_static_name, caption = {'vlayer.control-refresh'} }:style{ - width = 160 + width = 200 }:on_click(function(player, _, _) vlayer_gui_list_refresh(player) end) @@ -379,7 +358,7 @@ Gui.element{ name = Gui.unique_static_name, caption = {'vlayer.control-see'} }:style{ - width = 160 + width = 200 }:on_click(function(player, element, _) local target = element.parent[vlayer_gui_control_type.name].selected_index local n = element.parent[vlayer_gui_control_list.name].selected_index @@ -406,7 +385,7 @@ Gui.element{ name = Gui.unique_static_name, caption = {'vlayer.control-build'} }:style{ - width = 160 + width = 200 }:on_click(function(player, _, _) if Selection.is_selecting(player, SelectionConvertArea) then Selection.stop(player) @@ -426,7 +405,7 @@ Gui.element{ name = Gui.unique_static_name, caption = {'vlayer.control-remove'} }:style{ - width = 160 + width = 200 }:on_click(function(player, element, _) local target = element.parent[vlayer_gui_control_type.name].selected_index local n = element.parent[vlayer_gui_control_list.name].selected_index @@ -451,7 +430,7 @@ end) local vlayer_control_set = Gui.element(function(_, parent, name) local vlayer_set = parent.add{type='flow', direction='vertical', name=name} - local disp = Gui.scroll_table(vlayer_set, 320, 2, 'disp') + local disp = Gui.scroll_table(vlayer_set, 400, 2, 'disp') vlayer_gui_control_type(disp) vlayer_gui_control_list(disp) @@ -468,7 +447,7 @@ end) vlayer_container = Gui.element(function(definition, parent) local player = Gui.get_player_from_element(parent) - local container = Gui.container(parent, definition.name, 320) + local container = Gui.container(parent, definition.name, 400) vlayer_display_set(container, 'vlayer_st_1') local control_set = vlayer_control_set(container, 'vlayer_st_2') @@ -500,13 +479,26 @@ Event.on_nth_tick(config.update_tick_gui, function(_) local stats = vlayer.get_statistics() local items = vlayer.get_items() local vlayer_display = { - [vlayer_gui_display_item_solar_count.name] = format_number(items['solar-panel']), - [vlayer_gui_display_item_accumulator_count.name] = format_number(items['accumulator']), - [vlayer_gui_display_signal_remaining_surface_area_count.name] = format_number(stats.remaining_surface_area), - [vlayer_gui_display_signal_production_count.name] = format_energy(stats.energy_production, 'W'), - [vlayer_gui_display_signal_sustained_count.name] = format_energy(stats.energy_sustained, 'W'), - [vlayer_gui_display_signal_capacity_count.name] = format_energy(stats.energy_capacity, 'J'), - [vlayer_gui_display_signal_current_count.name] = format_energy(stats.energy_storage, 'J'), + [vlayer_gui_display_item_solar_count.name] = { + cap = format_number(items['solar-panel']) + }, + [vlayer_gui_display_item_accumulator_count.name] = { + cap = format_number(items['accumulator']) + }, + [vlayer_gui_display_signal_remaining_surface_area_count.name] = { + cap = format_number(stats.remaining_surface_area) + }, + [vlayer_gui_display_signal_sustained_count.name] = { + cap = format_energy(stats.energy_sustained, 'W') + }, + [vlayer_gui_display_signal_production_count.name] = { + val = (stats.energy_production / stats.energy_max) or 0, + cap = format_energy(stats.energy_production, '') .. ' / ' .. format_energy(stats.energy_max, '') + }, + [vlayer_gui_display_signal_capacity_count.name] = { + val = (stats.energy_storage / stats.energy_capacity) or 0, + cap = format_energy(stats.energy_storage, '') .. ' / ' .. format_energy(stats.energy_capacity, '') + } } for _, player in pairs(game.connected_players) do @@ -514,7 +506,11 @@ Event.on_nth_tick(config.update_tick_gui, function(_) local disp = frame.container['vlayer_st_1'].disp.table for k, v in pairs(vlayer_display) do - disp[k].caption = v + disp[k].caption = v.cap + + if v.val then + disp[k].value = v.val + end end end end) From 193616b3a18baac61e445a7fabbb9b229369bed1 Mon Sep 17 00:00:00 2001 From: PHIDIAS Date: Fri, 6 Sep 2024 03:29:47 +0900 Subject: [PATCH 03/10] Update vlayer.lua --- modules/gui/vlayer.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/gui/vlayer.lua b/modules/gui/vlayer.lua index 375a0ff472..0d310f15c0 100644 --- a/modules/gui/vlayer.lua +++ b/modules/gui/vlayer.lua @@ -492,11 +492,11 @@ Event.on_nth_tick(config.update_tick_gui, function(_) cap = format_energy(stats.energy_sustained, 'W') }, [vlayer_gui_display_signal_production_count.name] = { - val = (stats.energy_production / stats.energy_max) or 0, + val = (stats.energy_production / math.max(stats.energy_max, 1)), cap = format_energy(stats.energy_production, '') .. ' / ' .. format_energy(stats.energy_max, '') }, [vlayer_gui_display_signal_capacity_count.name] = { - val = (stats.energy_storage / stats.energy_capacity) or 0, + val = (stats.energy_storage / math.max(stats.energy_capacity, 1)), cap = format_energy(stats.energy_storage, '') .. ' / ' .. format_energy(stats.energy_capacity, '') } } From 74b46e8f1fab735d0188aa6036ae445c7cae2ef9 Mon Sep 17 00:00:00 2001 From: PHIDIAS Date: Fri, 6 Sep 2024 14:43:37 +0900 Subject: [PATCH 04/10] Update vlayer.lua --- modules/gui/vlayer.lua | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/modules/gui/vlayer.lua b/modules/gui/vlayer.lua index 0d310f15c0..bbb6417e99 100644 --- a/modules/gui/vlayer.lua +++ b/modules/gui/vlayer.lua @@ -147,12 +147,14 @@ Gui.element{ local vlayer_gui_display_item_solar_count = Gui.element{ - type = 'label', + type = 'progressbar', name = 'vlayer_display_item_solar_count', - caption = '0', - style = 'heading_2_label' + caption = '', + value = 0, + style = 'electric_satisfaction_statistics_progressbar' }:style{ - width = 200 + width = 200, + font = 'heading-3' } --- Display label for the number of accumulators @@ -169,12 +171,14 @@ Gui.element{ local vlayer_gui_display_item_accumulator_count = Gui.element{ - type = 'label', + type = 'progressbar', name = 'vlayer_display_item_accumulator_count', - caption = '0', - style = 'heading_2_label' + caption = '', + value = 0, + style = 'electric_satisfaction_statistics_progressbar' }:style{ - width = 200 + width = 200, + font = 'heading-3' } --- Display label for the remaining surface area @@ -197,7 +201,8 @@ Gui.element{ caption = '0', style = 'heading_2_label' }:style{ - width = 200 + width = 200, + horizontal_align = 'right' } --- Display label for the sustained energy production @@ -220,7 +225,8 @@ Gui.element{ caption = '0', style = 'heading_2_label' }:style{ - width = 200 + width = 200, + horizontal_align = 'right' } --- Display label for the current energy production @@ -417,7 +423,7 @@ Gui.element{ local interface_type, interface_position = vlayer.remove_interface(i[vlayer_control_type_list[target]][n].surface, i[vlayer_control_type_list[target]][n].position) if interface_type then - game.print{'vlayer.interface-result', player.name, pos_to_gps_string(interface_position), {'vlayer.result-remove'}, {'vlayer.control-type-' .. interface_type:gsub(' ', '-')}} + game.print{'vlayer.interface-result', player.name, pos_to_gps_string(interface_position), {'vlayer.result-remove'}, {'vlayer.control-type-' .. interface_type}} end end end @@ -478,12 +484,16 @@ Event.add(Roles.events.on_role_unassigned, role_update_event) Event.on_nth_tick(config.update_tick_gui, function(_) local stats = vlayer.get_statistics() local items = vlayer.get_items() + local items_alloc = vlayer.get_allocated_items() + local vlayer_display = { [vlayer_gui_display_item_solar_count.name] = { - cap = format_number(items['solar-panel']) + val = (items_alloc['solar-panel'] / math.max(items['solar-panel'], 1)), + cap = format_number(items_alloc['solar-panel']) .. ' / ' .. format_number(items['solar-panel']) }, [vlayer_gui_display_item_accumulator_count.name] = { - cap = format_number(items['accumulator']) + val = (items_alloc['accumulator'] / math.max(items['accumulator'], 1)), + cap = format_number(items_alloc['accumulator']) .. ' / ' .. format_number(items['accumulator']) }, [vlayer_gui_display_signal_remaining_surface_area_count.name] = { cap = format_number(stats.remaining_surface_area) From 3a296fe44cd419e35bac957b6a2720fcba151841 Mon Sep 17 00:00:00 2001 From: PHIDIAS Date: Fri, 6 Sep 2024 14:43:50 +0900 Subject: [PATCH 05/10] Update vlayer.lua --- modules/control/vlayer.lua | 64 ++++++++++++++++++++++++++++++++------ 1 file changed, 55 insertions(+), 9 deletions(-) diff --git a/modules/control/vlayer.lua b/modules/control/vlayer.lua index 6669df815c..db322a78ae 100644 --- a/modules/control/vlayer.lua +++ b/modules/control/vlayer.lua @@ -71,6 +71,39 @@ function vlayer.get_items() return vlayer_data.storage.items end +--- Get all unallocated items in storage +-- @treturn table a dictionary of all unallocated items stored in the vlayer +function vlayer.get_unallocated_items() + return vlayer_data.storage.unallocated +end + +--- Get all allocated items in storage +-- @treturn table a dictionary of all allocated items stored in the vlayer +function vlayer.get_allocated_items() + local r = {} + + for k, v in pairs(vlayer_data.storage.items) do + r[k] = v + + if vlayer_data.storage.unallocated[k] then + r[k] = r[k] - vlayer_data.storage.unallocated[k] + end + end + + return r +end + +--- Get the actual defecit of land +function get_actual_land_defecit() + local n = vlayer_data.properties.total_surface_area - vlayer_data.properties.used_surface_area + + for k, v in pairs(vlayer.get_unallocated_items()) do + n = n - (config.allowed_items[k].required_area * v) + end + + return n +end + --- Get interface counts -- @treturn table a dictionary of the vlayer interface counts function vlayer.get_interface_counts() @@ -240,7 +273,7 @@ function vlayer.insert_item(item_name, count) end --- Remove an item from the vlayer, this will decrement its count in storage and prioritise unallocated items over deallocation --- Can not always fulfil the remove request for items which provide surface area, therefore returns the amount actually removed +-- Can not always fulfill the remove request for items which provide surface area, therefore returns the amount actually removed -- @tparam string item_name The name of the item to remove -- @tparam number count The count of the item to remove -- @treturn number The count of the item actually removed @@ -282,6 +315,7 @@ function vlayer.remove_item(item_name, count) -- Remove the item from allocated storage vlayer_data.storage.items[item_name] = vlayer_data.storage.items[item_name] - remove_count vlayer.allocate_item(item_name, -remove_count) + return remove_unallocated + remove_count end @@ -309,6 +343,7 @@ function vlayer.create_input_interface(surface, position, circuit, last_user) interface.destructible = false interface.minable = false interface.operable = true + return interface end @@ -371,6 +406,7 @@ function vlayer.create_output_interface(surface, position, circuit, last_user) interface.destructible = false interface.minable = false interface.operable = true + return interface end @@ -424,6 +460,7 @@ local function handle_unallocated() -- Allocate items in an equal distribution local surplus_area = vlayer_data.properties.total_surface_area - vlayer_data.properties.used_surface_area + for item_name, count in pairs(vlayer_data.storage.unallocated) do local allocation_count = math.min(count, math.floor(count * surplus_area / unallocated_area)) @@ -436,14 +473,17 @@ end --- Get the statistics for the vlayer function vlayer.get_statistics() + local vdp = vlayer_data.properties.production * mega + local gdm = get_production_multiplier() + return { total_surface_area = vlayer_data.properties.total_surface_area, used_surface_area = vlayer_data.properties.used_surface_area, - remaining_surface_area = vlayer_data.properties.total_surface_area - vlayer_data.properties.used_surface_area, - production_multiplier = get_production_multiplier(), - energy_max = vlayer_data.properties.production * mega, - energy_production = vlayer_data.properties.production * mega * get_production_multiplier(), - energy_sustained = vlayer_data.properties.production * mega * get_sustained_multiplier(), + remaining_surface_area = get_actual_land_defecit(), + production_multiplier = gdm, + energy_max = vdp, + energy_production = vdp * gdm, + energy_sustained = vdp * get_sustained_multiplier(), energy_capacity = vlayer_data.properties.capacity * mega, energy_storage = vlayer_data.storage.energy, day_time = math.floor(vlayer_data.surface.daytime * vlayer_data.surface.ticks_per_day), @@ -498,6 +538,7 @@ function vlayer.create_circuit_interface(surface, position, circuit, last_user) interface.destructible = false interface.minable = false interface.operable = true + return interface end @@ -577,6 +618,7 @@ function vlayer.create_energy_interface(surface, position, last_user) interface.power_production = 0 interface.power_usage = 0 interface.energy = 0 + return interface end @@ -603,7 +645,7 @@ local function handle_energy_interfaces() local discharge_rate = 2 * (production + vlayer_data.properties.discharge * mega) / #vlayer_data.entity_interfaces.energy local fill_to = math.min(discharge_rate, math.floor(available_energy / #vlayer_data.entity_interfaces.energy)) - for index, interface in pairs(vlayer_data.entity_interfaces.energy) do + for _, interface in pairs(vlayer_data.entity_interfaces.energy) do interface.electric_buffer_size = math.max(discharge_rate, interface.energy) -- prevent energy loss local delta = fill_to - interface.energy -- positive means storage to interface vlayer_data.storage.energy = vlayer_data.storage.energy - delta @@ -657,23 +699,27 @@ function vlayer.remove_interface(surface, position) move_items_stack(interface.get_inventory(defines.inventory.chest).get_contents()) table.remove_element(vlayer_data.entity_interfaces.storage_input, interface) interface.destroy() - return 'storage input', pos + + return 'storage-input', pos elseif name == 'logistic-chest-requester' then move_items_stack(interface.get_inventory(defines.inventory.chest).get_contents()) table.remove_element(vlayer_data.entity_interfaces.storage_output, interface) interface.destroy() - return 'storage output', pos + + return 'storage-output', pos elseif name == 'constant-combinator' then table.remove_element(vlayer_data.entity_interfaces.circuit, interface) interface.destroy() + return 'circuit', pos elseif name == 'electric-energy-interface' then vlayer_data.storage.energy = vlayer_data.storage.energy + interface.energy table.remove_element(vlayer_data.entity_interfaces.energy, interface) interface.destroy() + return 'energy', pos end end From e0c103ece5822ddb6126694af016611c63452c7d Mon Sep 17 00:00:00 2001 From: PHIDIAS Date: Fri, 6 Sep 2024 14:46:13 +0900 Subject: [PATCH 06/10] Update vlayer.lua --- modules/control/vlayer.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/control/vlayer.lua b/modules/control/vlayer.lua index db322a78ae..4411983cb8 100644 --- a/modules/control/vlayer.lua +++ b/modules/control/vlayer.lua @@ -94,7 +94,7 @@ function vlayer.get_allocated_items() end --- Get the actual defecit of land -function get_actual_land_defecit() +local function get_actual_land_defecit() local n = vlayer_data.properties.total_surface_area - vlayer_data.properties.used_surface_area for k, v in pairs(vlayer.get_unallocated_items()) do From 007a89a6987196564868db935f6c394a9db00557 Mon Sep 17 00:00:00 2001 From: PHIDIAS Date: Fri, 6 Sep 2024 14:52:30 +0900 Subject: [PATCH 07/10] Update vlayer.lua --- modules/gui/vlayer.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/gui/vlayer.lua b/modules/gui/vlayer.lua index bbb6417e99..000bb5ad72 100644 --- a/modules/gui/vlayer.lua +++ b/modules/gui/vlayer.lua @@ -503,11 +503,11 @@ Event.on_nth_tick(config.update_tick_gui, function(_) }, [vlayer_gui_display_signal_production_count.name] = { val = (stats.energy_production / math.max(stats.energy_max, 1)), - cap = format_energy(stats.energy_production, '') .. ' / ' .. format_energy(stats.energy_max, '') + cap = format_energy(stats.energy_production, 'W') .. ' / ' .. format_energy(stats.energy_max, 'W') }, [vlayer_gui_display_signal_capacity_count.name] = { val = (stats.energy_storage / math.max(stats.energy_capacity, 1)), - cap = format_energy(stats.energy_storage, '') .. ' / ' .. format_energy(stats.energy_capacity, '') + cap = format_energy(stats.energy_storage, 'J') .. ' / ' .. format_energy(stats.energy_capacity, 'J') } } From ef1e062fd7580ce37e2d1e628f237a77374c5f0f Mon Sep 17 00:00:00 2001 From: PHIDIAS Date: Sat, 7 Sep 2024 01:16:41 +0900 Subject: [PATCH 08/10] Update vlayer.lua --- modules/control/vlayer.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/control/vlayer.lua b/modules/control/vlayer.lua index 4411983cb8..5513b2b6a3 100644 --- a/modules/control/vlayer.lua +++ b/modules/control/vlayer.lua @@ -273,7 +273,7 @@ function vlayer.insert_item(item_name, count) end --- Remove an item from the vlayer, this will decrement its count in storage and prioritise unallocated items over deallocation --- Can not always fulfill the remove request for items which provide surface area, therefore returns the amount actually removed +-- Can not always fulfil the remove request for items which provide surface area, therefore returns the amount actually removed -- @tparam string item_name The name of the item to remove -- @tparam number count The count of the item to remove -- @treturn number The count of the item actually removed From b244f515fcbcce54c34e1832cd95049c820bd8b0 Mon Sep 17 00:00:00 2001 From: PHIDIAS Date: Sun, 8 Sep 2024 02:00:44 +0900 Subject: [PATCH 09/10] Update vlayer.lua --- modules/control/vlayer.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/control/vlayer.lua b/modules/control/vlayer.lua index 5513b2b6a3..81313270b1 100644 --- a/modules/control/vlayer.lua +++ b/modules/control/vlayer.lua @@ -663,7 +663,8 @@ local function handle_energy_interfaces() local max_burning = (vlayer_data.properties.capacity * mega / 2) - vlayer_data.storage.energy if v.count > 0 and max_burning > 0 then - local to_burn = math.min(v.count, max_burning / v.value) + local to_burn = math.min(v.count, math.floor(max_burning / v.value)) + vlayer_data.storage.energy = vlayer_data.storage.energy + (to_burn * v.value) vlayer_data.storage.power_items[k].count = vlayer_data.storage.power_items[k].count - to_burn end From 62fcca4a64e2849b0520a2f5d68c70a4c647f277 Mon Sep 17 00:00:00 2001 From: PHIDIAS Date: Mon, 9 Sep 2024 15:38:25 +0900 Subject: [PATCH 10/10] Update vlayer.lua --- modules/gui/vlayer.lua | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/modules/gui/vlayer.lua b/modules/gui/vlayer.lua index 000bb5ad72..928663f18d 100644 --- a/modules/gui/vlayer.lua +++ b/modules/gui/vlayer.lua @@ -154,7 +154,7 @@ Gui.element{ style = 'electric_satisfaction_statistics_progressbar' }:style{ width = 200, - font = 'heading-3' + font = 'heading-2' } --- Display label for the number of accumulators @@ -178,7 +178,7 @@ Gui.element{ style = 'electric_satisfaction_statistics_progressbar' }:style{ width = 200, - font = 'heading-3' + font = 'heading-2' } --- Display label for the remaining surface area @@ -202,6 +202,7 @@ Gui.element{ style = 'heading_2_label' }:style{ width = 200, + height = 28, horizontal_align = 'right' } @@ -226,6 +227,7 @@ Gui.element{ style = 'heading_2_label' }:style{ width = 200, + height = 28, horizontal_align = 'right' } @@ -251,7 +253,7 @@ Gui.element{ style = 'electric_satisfaction_statistics_progressbar' }:style{ width = 200, - font = 'heading-3' + font = 'heading-2' } --- Display label for the sustained energy capacity @@ -276,7 +278,7 @@ Gui.element{ style = 'electric_satisfaction_statistics_progressbar' }:style{ width = 200, - font = 'heading-3' + font = 'heading-2' } --- A vertical flow containing all the displays labels and their counts @@ -369,7 +371,7 @@ Gui.element{ local target = element.parent[vlayer_gui_control_type.name].selected_index local n = element.parent[vlayer_gui_control_list.name].selected_index - if target and vlayer_control_type_list[target] and n then + if target and vlayer_control_type_list[target] and n > 0 then local i = vlayer.get_interfaces() if i and i[vlayer_control_type_list[target]] and i[vlayer_control_type_list[target]][n] then @@ -416,7 +418,7 @@ Gui.element{ local target = element.parent[vlayer_gui_control_type.name].selected_index local n = element.parent[vlayer_gui_control_list.name].selected_index - if target and vlayer_control_type_list[target] and n then + if target and vlayer_control_type_list[target] and n > 0 then local i = vlayer.get_interfaces() if i and i[vlayer_control_type_list[target]] then