Skip to content

Commit 345c978

Browse files
committed
chore: Merge branch 'development' into trunk
2 parents d3b7866 + 77445de commit 345c978

File tree

5 files changed

+433
-206
lines changed

5 files changed

+433
-206
lines changed

gui/gui.lua

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,11 @@ local function on_gui_opened(event)
230230
if event.gui_type == defines.gui_type.entity then
231231
local parent = player.gui.relative
232232
local entity = event.entity
233-
local gui = relative_gui_for_entity_type[entity and entity.valid and entity.type]
233+
if not entity or not entity.valid then return destroy_on(parent) end
234+
235+
local entity_type = entity.type
236+
if entity_type == "entity-ghost" then entity_type = entity.ghost_type end
237+
local gui = relative_gui_for_entity_type[entity_type]
234238
if not gui then return destroy_on(parent) end
235239
return render_on(parent, { gui = gui, position = defines.relative_gui_position.right })
236240
elseif event.gui_type == defines.gui_type.custom then
@@ -245,7 +249,7 @@ end
245249
local function on_gui_checked_state_changed(event)
246250
local element = event.element
247251
local tags = element.tags --[[@as { mode: action, action: string }?]]
248-
if not element.get_mod() == "inventory-selector" or not tags then return end
252+
if element.get_mod() ~= "inventory-selector" or not tags then return end
249253
local player = game.get_player(event.player_index) --[[@as LuaPlayer]]
250254
if not player or not player.valid then return end
251255
local entity = player.opened --[[@as LuaEntity]]
@@ -256,14 +260,19 @@ local function on_gui_checked_state_changed(event)
256260
elseif tags.action == "circuit_set" then
257261
selector.set_circuit_mode(entity, tags.mode, event.element.state)
258262
end
259-
return render_on(player.gui.relative, { gui = relative_gui_for_entity_type[entity.type], position = defines.relative_gui_position.right })
263+
264+
local entity_type = entity.type
265+
if entity_type == "entity-ghost" then entity_type = entity.ghost_type end
266+
local gui = relative_gui_for_entity_type[entity_type]
267+
268+
return render_on(player.gui.relative, { gui = gui, position = defines.relative_gui_position.right })
260269
end
261270

262271
---@param event EventData.on_gui_elem_changed
263272
local function on_gui_elem_changed(event)
264273
local element = event.element
265274
local tags = element.tags --[[@as { mode: action }?]]
266-
if not element.get_mod() == "inventory-selector" or not tags then return end
275+
if element.get_mod() ~= "inventory-selector" or not tags then return end
267276
local player = game.get_player(event.player_index) --[[@as LuaPlayer]]
268277
if not player or not player.valid then return end
269278
local entity = player.opened --[[@as LuaEntity]]
@@ -274,7 +283,12 @@ local function on_gui_elem_changed(event)
274283
local name = select(3, string.find(elem or "", "^inventory%-selector%-inventory%-([_%a]+)$")) or "none"
275284

276285
selector.set(entity, tags.mode, name, true)
277-
return render_on(player.gui.relative, { gui = relative_gui_for_entity_type[entity.type], position = defines.relative_gui_position.right })
286+
287+
local entity_type = entity.type
288+
if entity_type == "entity-ghost" then entity_type = entity.ghost_type end
289+
local gui = relative_gui_for_entity_type[entity_type]
290+
291+
return render_on(player.gui.relative, { gui = gui, position = defines.relative_gui_position.right })
278292
end
279293

280294
-- TODO: Need to watch for externally triggered changes to the entity shown in the open GUI
@@ -298,9 +312,12 @@ return {
298312
end
299313
for _, player in pairs(game.players) do
300314
if player.valid and player.opened_gui_type == defines.gui_type.entity then
301-
local anchor_gui = relative_gui_for_entity_type[player.opened.type]
302-
if anchor_gui then
303-
render_on(player.gui.relative, { gui = anchor_gui, position = defines.relative_gui_position.right })
315+
local entity = player.opened --[[@as LuaEntity]]
316+
local entity_type = entity and entity.valid and entity.type
317+
if entity_type == "entity-ghost" then entity_type = entity.ghost_type end
318+
local gui = relative_gui_for_entity_type[entity_type]
319+
if gui then
320+
render_on(player.gui.relative, { gui = gui, position = defines.relative_gui_position.right })
304321
end
305322
end
306323
end

locale/en/locale.cfg

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ inventory-selector-support-entities-filtered=Filtered inserters
3333
inventory-selector-support-entities-inserters=Any inserters
3434
inventory-selector-support-entities-all=Anything that drops items
3535
inventory-selector-deadlock-safety-always-immediate=Always immediate
36-
inventory-selector-deadlock-safety-allow-safe=Allow safe
3736
inventory-selector-deadlock-safety-allow-unsafe=Allow unsafe
3837
inventory-selector-deadlock-safety-always-safe=Always safe
3938
inventory-selector-enable-inventory-base=Base-game equivalent
@@ -44,7 +43,6 @@ inventory-selector-support-entities-filtered=Allow configuration of inserters on
4443
inventory-selector-support-entities-inserters=Allow configuration of any kind of inserter.
4544
inventory-selector-support-entities-all=Allow configuration of any kind of entity that can drop items nearby.\n\nThis additionally includes mining drills, recyclers, and any modded crafting machines that define a drop position for their output.
4645
inventory-selector-deadlock-safety-always-immediate=Always apply changes immediately, disabling deadlock mitigation completely.\n\nThis setting is ideal for control freaks and power users, giving your factory the power to deadlock itself at any moment because of an automated change to inserter settings.\n\n[img=warning-white] Switching to this mode mid-game will cause any previously deferred changes to be applied immediately (or more accurately on their next attempt, which is practically immediate).
47-
inventory-selector-deadlock-safety-allow-safe=Changes are applied immediately, with risky changes only deferred if safe behavior is specifically requested.\n\nThis is an alternative to the standard mode ("Allow Unsafe"), differing only in the default behavior when not explicitly specified.
4846
inventory-selector-deadlock-safety-allow-unsafe=Changes are automatically deferred when risky, unless immediate behavior is specifically requested (e.g. by a GUI interaction).\n\nThis allows most automated control to operate safely while enabling direct control by players similar to other settings. This is the default setting, ideal for engineers expecting sensible vanilla-like behavior in most situations.
4947
inventory-selector-deadlock-safety-always-safe=Risky changes are always deferred, potentially indefinitely.\n\nThis setting is ideal for those who do not trust their fellow engineers (or themselves) not to accidentally deadlock an inserter while configuring it, though possibly causing confusion for users expecting an instant response.
5048
inventory-selector-enable-inventory-base=Only allow selection of inventories that are generally accessible in the base game.\n\nThis setting still provides additional control, which may permit modes of interaction not otherwise possible in the base game.

script/limbo.lua

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
local inventory = require("script.inventory")
22

3-
-- Create a remapping for limbo container entities, which forwards all inventory types to the "storage" chest inventory
3+
-- Create a remapping for limbo container entities, which forwards all inventory types to the "main" chest inventory
44
local limbo_remap = { "main", "closed" }
55
inventory.register_inventory_remap({ name = "inventory-selector-limbo", base = "container" }, {
66
ammo = limbo_remap,
@@ -22,18 +22,7 @@ local origin = {0, 0}
2222

2323
-- Maintains "limbo" containers that can be used as the target of a proxy container to prevent inserters from losing interest in them
2424
-- See: https://forums.factorio.com/viewtopic.php?t=127774 for relevant discussion
25-
--
26-
-- This is a workaround: limbo containers provide a cheap and easy(?) target with probably no side effects ever. Though a single
27-
-- limbo container could suffice for proxies across all surfaces, creating at least one per surface ensures they are unlikely to be
28-
-- destroyed out of sync with the proxies that depend on them. Ensuring proxies never have an invalid target inventory is essential
29-
-- in order to maintain functional correctness of the features provided by this mod.
30-
--
31-
-- We could watch for surface creation and destruction events, but this seems unnecessary for now. They are created lazily, and if a
32-
-- surface is ever destroyed, everything referring to it should have been destroyed as well.
33-
--
34-
-- The strong need for these has been mostly resolved by changes to inserter behavior in 2.0.44, though this version introduces new
35-
-- issues because of the change to the behavior of entity prototype flags concerning automated interaction.
36-
-- TODO: Open a new bug report for these issues once explored a bit more.
25+
-- These are no longer strictly necessary in 2.0.44, but still provide a way to specify an explicitly unusable (but valid) inventory.
3726
local limbo = setmetatable({}, {
3827
---@param surface_index uint
3928
---@return LuaEntity?

0 commit comments

Comments
 (0)