From d002eeaf54e0db2a54081db35e2f1a1264888d87 Mon Sep 17 00:00:00 2001 From: PHIDIAS Date: Sat, 25 Jan 2025 00:43:03 +0900 Subject: [PATCH] Add option for vlayer on space platforms (#365) * Update vlayer.lua * Update vlayer.lua * Update vlayer.lua --- exp_legacy/module/config/vlayer.lua | 1 + exp_legacy/module/modules/gui/vlayer.lua | 12 +++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/exp_legacy/module/config/vlayer.lua b/exp_legacy/module/config/vlayer.lua index c008c41a..a3eac3ad 100644 --- a/exp_legacy/module/config/vlayer.lua +++ b/exp_legacy/module/config/vlayer.lua @@ -9,6 +9,7 @@ return { unlimited_capacity = false, --- @setting unlimited_capacity When true the vlayer has an unlimited energy capacity, accumulators are not required unlimited_surface_area = false, --- @setting unlimited_surface_area When true the vlayer has an unlimited surface area, landfill is not required modded_auto_downgrade = false, --- @setting modded_auto_downgrade When true modded items will be converted into their base game equivalent, original items can not be recovered + power_on_space = false, --- @setting power_on_space When true allow on spaceship mimic_surface = "nauvis", --- @setting mimic_surface Surface name/index the vlayer will copy its settings from, use nil to use the settings below surface = { --- @setting surface When mimic_surface is nil these settings will be used instead, see LuaSurface for details diff --git a/exp_legacy/module/modules/gui/vlayer.lua b/exp_legacy/module/modules/gui/vlayer.lua index 12595259..15e6af02 100644 --- a/exp_legacy/module/modules/gui/vlayer.lua +++ b/exp_legacy/module/modules/gui/vlayer.lua @@ -81,10 +81,16 @@ Selection.on_selection(SelectionConvertArea, function(event) return nil end - local entities = event.surface.find_entities_filtered{ area = area, name = "steel-chest", force = player.force } local frame = Gui.get_left_element(player, vlayer_container) local disp = frame.container["vlayer_st_2"].disp.table local target = vlayer_control_type_list[disp[vlayer_gui_control_type.name].selected_index] + local entities + + if config.power_on_space and event.surface and event.surface.platform and target == "energy" then + entities = event.surface.find_entities_filtered{ area = area, name = "constant-combinator", force = player.force } + else + entities = event.surface.find_entities_filtered{ area = area, name = "steel-chest", force = player.force } + end if #entities == 0 then player.print{ "vlayer.steel-chest-detect" } @@ -100,9 +106,9 @@ Selection.on_selection(SelectionConvertArea, function(event) local e = entities[1] local e_pos = { x = string.format("%.1f", e.position.x), y = string.format("%.1f", e.position.y) } - local e_circ = {} -- e.circuit_connected_entities --- TODO use new circuit api + local e_circ = nil -- e.get_wire_connectors{ or_create = false } - if not e.get_inventory(defines.inventory.chest).is_empty() then + if e.name and e.name == "steel-chest" and (not e.get_inventory(defines.inventory.chest).is_empty()) then player.print{ "vlayer.steel-chest-empty" } return nil end