Page 1 of 1

alt_reverse_selection for Selection tools

Posted: Sun May 22, 2022 12:18 pm
by ickputzdirwech
I would like to create a selection tool that does the following things:
  • selection = Do something to all selected entities.
  • reverse_selection = Do the opposite to all selected entities.
  • alt_selection = Do something to all not selected entities.
  • alt_reverse_selection = Do the opposite to all not selected entities.
Unfortunately alt_reverse_selection does not exist yet. Any chance you might add this?

Another potentially usecase could be the upgrade planner:
  • selection = Upgrade
  • reverse_selection = Downgrade
  • alt_selection = Cancel upgrades (right now this cancels all up- and downgrades)
  • alt_reverse_selection = Cancel downgrades

Re: alt_reverse_selection for Selection tools

Posted: Tue May 24, 2022 1:08 pm
by Qon
ickputzdirwech wrote:
Sun May 22, 2022 12:18 pm
I would like to create a selection tool that does the following things:
  • alt_selection = Do something to all not selected entities.
  • alt_reverse_selection = Do the opposite to all not selected entities.
You want a tool to do something to every entity on every surface, except the things inside the selection area? So basically selecting things outside the rectangle? Sounds like it might easily lead to disaster and major performance issues, potentially game crashing, for you to avoid zooming out of the map and make a few bigger selections. When would this ever be useful? And why would you need api support for something this rare? You could make an alt selection tool yourself with the current api anyways already (just calculate what entities exist outside the area or set of entities given by the current api).

Re: alt_reverse_selection for Selection tools

Posted: Tue May 24, 2022 1:35 pm
by FuryoftheStars
Qon wrote:
Tue May 24, 2022 1:08 pm
ickputzdirwech wrote:
Sun May 22, 2022 12:18 pm
I would like to create a selection tool that does the following things:
  • alt_selection = Do something to all not selected entities.
  • alt_reverse_selection = Do the opposite to all not selected entities.
You want a tool to do something to every entity on every surface, except the things inside the selection area? So basically selecting things outside the rectangle? Sounds like it might easily lead to disaster and major performance issues, potentially game crashing, for you to avoid zooming out of the map and make a few bigger selections. When would this ever be useful? And why would you need api support for something this rare? You could make an alt selection tool yourself with the current api anyways already (just calculate what entities exist outside the area or set of entities given by the current api).
I think what might be meant by "all not selected entities" is entities within the selection area that were not actually selected due to the filtering criteria.

Re: alt_reverse_selection for Selection tools

Posted: Tue May 24, 2022 5:15 pm
by ickputzdirwech
I won't deny that my specific use case might be a bit obscure. I think it's important to clarify that adding alt_reverse_selection would allow the following schema:
  1. do something
  2. do the opposite
  3. reverse 1
  4. reverse 2
That the fourth option doesn't exists, feels like a whole in the matrix to me. Adding a second tool would mean that the player would have to actively pick the right one and would have to switch between them (very inconvenient):

For those of you who are interested in the specific problem I want to solve:

In the Shortcuts for 1.1 mod I have an artillery toggle selection tool. Right now it disables all selected enabled artillery turrets AND enables all selected disabled artillery turrets. I would like to change it from a toggle to an enable/disable behaviour. Then it would either enable all selected disabled artillery turrets (normal selection) OR disable all selected enabled artillery turrets (reverse selection). At the same time I would like to add an "all-except-selected" mode. Then it could also enable all non-selected disabled artillery turrets (alt_selection) OR disable all non-selected enabled artillery turrets (alt_reverse_selection).

Right now I can only implement one of the two ideas at the same time.

And if you are worried about performance. Doing a find_entities_filtered isn't that bad if triggered only once in a while with a very limit amount of entities to look for.

Re: alt_reverse_selection for Selection tools

Posted: Wed May 25, 2022 1:01 am
by Qon
ickputzdirwech wrote:
Tue May 24, 2022 5:15 pm

That the fourth option doesn't exists, feels like a whole in the matrix to me.
Seems reasonable. I agree with this.

What I'm against is for selection tools by default to have a modifier to select the things outside the region. And I don't think you want it for your tool either. It's going to confuse users and be clunkier than the alternative.
ickputzdirwech wrote:
Tue May 24, 2022 5:15 pm

For those of you who are interested in the specific problem I want to solve:

In the Shortcuts for 1.1 mod I have an artillery toggle selection tool. Right now it disables all selected enabled artillery turrets AND enables all selected disabled artillery turrets. I would like to change it from a toggle to an enable/disable behaviour. Then it would either enable all selected disabled artillery turrets (normal selection) OR disable all selected enabled artillery turrets (reverse selection). At the same time I would like to add an "all-except-selected" mode. Then it could also enable all non-selected disabled artillery turrets (alt_selection) OR disable all non-selected enabled artillery turrets (alt_reverse_selection).
A second tool that selects outside is also bad. And I agree that it should be one tool. But instead of doing outside region selections, have gui buttons on top or left area appear only while holding the tool that disable and enable all turrets. Then you can use the tool to enable (or disable) the selected turrets. This way making multiple enabled regions is also consistent. Instead of doing one weird outside selection that disables things outside the selection (and not leaving things inside in a known state) and then doing normal selection-enable actions for additional regions, you disable all and then mark the regions you want to enable.

Re: alt_reverse_selection for Selection tools

Posted: Mon Sep 12, 2022 10:41 pm
by Xorimuth
+1 for alt_reverse_selection, would be useful for a simplified version of Module Inserter that I'm currently working on.

Re: alt_reverse_selection for Selection tools

Posted: Tue Sep 13, 2022 4:01 pm
by _CodeGreen
Would making the tool strictly enable turrets on normal select and disable turrets on alt select work? It doesn't have to be a toggle, it could be like all of the other planners in the game.

Re: alt_reverse_selection for Selection tools

Posted: Fri Nov 04, 2022 12:26 pm
by Xorimuth
Added in 1.1.71