Selection tool behavior when clicking on entities

Place to get help with not working mods / modding interface.
Post Reply
robot256
Filter Inserter
Filter Inserter
Posts: 596
Joined: Sun Mar 17, 2019 1:52 am
Contact:

Selection tool behavior when clicking on entities

Post by robot256 »

In the mod Vehicle Wagon 2, it used to use a capsule to select which car and wagon to load. This worked by triggering an event whenever the player clicked with capsule and reading player.selected as the entity they are hovering over. The downside is that you cannot use capsules in map view at an arbitrary distance.

I have changed the capsule to a selection tool. This works fine, and you can even select both the vehicle and the wagon at once to load them. You can also (usually) use it like the old winch, single-clicking on each entity to make selections. But there is a frustrating behavior where you hover over an entity with the winch, the selection box visualization appears, and you click with the winch tool, but nothing is selected. No event is generated because the "selected area" contains no entities filtered according to the rules that I set, so I cannot read the cursor position or selected entity after the player releases the button.

The problem is caused by the bounding or collision box of the entity being different from the selection box. The selection tool only selects the "ground footprint" of entities because that is how blueprinting should work, but blueprints don't apply to vehicles so the behavior is not intuitive there. It is most dramatic on the Spidertron, because the selection box and the bounding box have almost no overlap. But it also happens on train wagons in certain orientations.


Here, it looks like when you click it should select the Spidertron:
hover_over_selection_box_center.jpg
hover_over_selection_box_center.jpg (490.47 KiB) Viewed 453 times

But when you actually click, it does not:
click_on_selection_box_center.jpg
click_on_selection_box_center.jpg (441.26 KiB) Viewed 453 times

At the very bottom of the selection box, it does what you expect:
click_on_selection_box_bottom.jpg
click_on_selection_box_bottom.jpg (388.29 KiB) Viewed 453 times

Hovering below the selection box, no indication is given that anything will happen if you click:
hover_outside_selection_box.jpg
hover_outside_selection_box.jpg (444.47 KiB) Viewed 453 times

But in fact the Spidertron will be selected:
click_outside_selection_box.jpg
click_outside_selection_box.jpg (441.99 KiB) Viewed 453 times

Does anyone have a suggestion for how to make this kind of tool more user friendly? I don't see a way to change the selection-tool to use selection boxes rather than bounding boxes to decide what to select, or any way to differentiate between a click and a drag. Do I have to respond to every area_selected event (even when no entities are selected) and perform the check myself, for example?

Post Reply

Return to “Modding help”