[2.0.50] "same-force" flag in SelectionModeData mode does not work

Bugs that are actually features.
sOvr9000
Inserter
Inserter
Posts: 26
Joined: Mon Jun 27, 2016 5:43 am
Contact:

[2.0.50] "same-force" flag in SelectionModeData mode does not work

Post by sOvr9000 »

05-16-2025, 12-58-20.png
05-16-2025, 12-58-20.png (3.98 MiB) Viewed 192 times
05-16-2025, 13-01-28.png
05-16-2025, 13-01-28.png (25.74 KiB) Viewed 192 times
My mod adds a selection tool that should select certain entities. With a very permissive `mode = {"same-force"}` and no entity filter, the selection tool should be able to select the burner mining drill and my custom entity, but it doesn't.

Steps to reproduce the bug:
1. Enable my mod, attached to this post.
2. Start new game with default map and mod settings.
3. Try to select any entity from the player force, such as a player-built burner mining drill.
Attachments
hextorio_0.3.2.zip
(2.18 MiB) Downloaded 16 times
Pi-C
Smart Inserter
Smart Inserter
Posts: 1746
Joined: Sun Oct 14, 2018 8:13 am
Contact:

Re: [2.0.50] "same-force" flag in SelectionModeData mode does not work

Post by Pi-C »

It seems you need to specify more than just "same-force" (either in flags or in entity_filters/entity_type_filters). I've added "any-entity" to flags:
Screenshot at 2025-05-17 13-06-32.png
Screenshot at 2025-05-17 13-06-32.png (3.15 MiB) Viewed 150 times
I've started the game and built the stone-furnace. Then, I used

Code: Select all

/c p = game.player; p.force = "neutral"
and placed the iron chest + burner mining drill. The selection was made while I was still in force "neutral", so it doesn't include the stone-furnace because it is not of the same force as the player.
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!
User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 3930
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: [2.0.50] "same-force" flag in SelectionModeData mode does not work

Post by boskid »

Thanks for the report. Answer provided by Pi-C is accurate: you need to specify "any-entity" for the selection tool to work.

Extended explanation involves describing some implementation details that may need to be added to documentation given that it happened to not be obvious. There are effectively 3 groups of mode flags: "negative filters", "positive filters" and "extras".

Negative filters involve: "nothing", "avoid-rolling-stock", "avoid-vehicle", "same-force", "not-same-force", "friend" and "enemy". Those filters on their own can only make entities selected by other filters to become rejected. For instance "nothing" filter rejects all entities given. "same-force" is a filter that rejects entities of different force. They do not select entities on their own but are usable as filters to exclude entities.

Positive filters involve: "any-entity", "entity-with-health", "is-military-target", "entity-with-owner", "items", "trees", "buildable-type", "items-to-place" (has items to place), "controllable", "controllable-add", "controllable-remove", "entity-ghost" and "tile-ghost". One of those filters passing is sufficient for entity to be selected (given it was not rejected by negative filters).

Extra filters are a weird mix between positive and negative filters, those are "blueprint", "deconstruct", "cancel-deconstruct", "upgrade", "cancel-upgrade" and "downgrade". This is best described starting from the original issue that made them not be a true "positive filters": there was a need for weird ability of making cut-tool to select only entities that match 2 conditions at the same time, a "blueprint" and "deconstruct", because only blueprintable entities can be put into blueprint however cut tool should not select entities that are marked as not deconstructible so in those cases both of those conditions must be fulfilled. This extra filters set has its own special rules because of that: when any of those extra filters is used, then original set of positive filters is ignored, instead only negative filters and those extra filters are checked: entity must match all of the selected extra filters to become selected.
Post Reply

Return to “Not a bug”