Detect clicked position in map view

Place to get help with not working mods / modding interface.
Pi-C
Smart Inserter
Smart Inserter
Posts: 1759
Joined: Sun Oct 14, 2018 8:13 am
Contact:

Detect clicked position in map view

Post by Pi-C »

In Autodrive, we have a "selection-tool" entity that is used to select either "car" entities in an area or to get the selected position (if the area is small enough, using the tool will be interpreted as "click on a position" instead of "area selected" ). This works in normal mode. In mapview, it works if the player has zoomed in:
Selecting a position works in zoomed-in mapview.
Selecting a position works in zoomed-in mapview.
select.png (3.93 MiB) Viewed 468 times
However, it doesn't work if the map is zoomed out to schematic view:
Selecting a position works not if mapview is zoomed out.
Selecting a position works not if mapview is zoomed out.
no_select.png (74.23 KiB) Viewed 468 times
There was a request to enable selecting a position on the zoomed out map. I've already thought about reacting to on_chart_tag_added -- but I'd still need a way to add a chart tag on click, so players can still use the item in their cursor instead of another input. I guess for that approach to work I'd need to detect when map view is toggled.

So, is there any way I can get a clicked position in map view?
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!
User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2905
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: Detect clicked position in map view

Post by darkfrei »

Pi-C wrote: Wed May 20, 2020 7:54 am I've already thought about reacting to on_chart_tag_added -- but I'd still need a way to add a chart tag on click, so players can still use the item in their cursor instead of another input. I guess for that approach to work I'd need to detect when map view is toggled.
How about to set the tag when the player on the map with item clicks?

If the player have "train" in the cursor and clicks on the map, then here comes the tag without text, may be only for some short time. You can catch it and delete after click.

But viewforum.php?f=28
Pi-C
Smart Inserter
Smart Inserter
Posts: 1759
Joined: Sun Oct 14, 2018 8:13 am
Contact:

Re: Detect clicked position in map view

Post by Pi-C »

darkfrei wrote: Wed May 20, 2020 2:34 pm
Pi-C wrote: Wed May 20, 2020 7:54 am I've already thought about reacting to on_chart_tag_added -- but I'd still need a way to add a chart tag on click, so players can still use the item in their cursor instead of another input. I guess for that approach to work I'd need to detect when map view is toggled.
How about to set the tag when the player on the map with item clicks?
The remote control from Autodrive is not of type "item", but "selection-tool". I'd need to exchange these when map view is toggled, but I can't find an event for it.

Do you mean I should make an interface request?
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!
Post Reply

Return to “Modding help”