How to use GPS tags?

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

How to use GPS tags?

Post by Pi-C »

How do I use GPS tags correctly? As of 0.18.35, they are supposed to support surface information. But when I add it, clicking the GPS tag won't show me the correct position.

This works:

Code: Select all

/c pos = game.player.position
/c game.print(string.format("[gps=%s, %s]", pos.x, pos.y))
As expected, when I click on the tag, view changes to map mode and the position is marked.

This doesn't work:

Code: Select all

/c pos = game.player.position
/c game.print(string.format("[gps=%s, %s, %s]", pos.x, pos.y, game.player.surface.name))
No matter what surface name I use, clicking the tag will not switch to map view and will not mark the position.
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: 2886
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: How to use GPS tags?

Post by boskid »

Ping coordinates should not use any spaces, at least before and after the surface name part.
When no surface name is given, ping is assumed to point at "nauvis".
Clicking a ping while being on another surface does nothing by itself except of sending an InputAction which then is responsible of raising on_player_clicked_gps_tag lua event where you can change surface and controller however you like.

Pi-C
Smart Inserter
Smart Inserter
Posts: 1724
Joined: Sun Oct 14, 2018 8:13 am
Contact:

Re: How to use GPS tags?

Post by Pi-C »

Thanks for your help!
boskid wrote:
Sat Dec 11, 2021 2:51 pm
Ping coordinates should not use any spaces, at least before and after the surface name part.
Oh, right. Leaving out the spaces will mark the position now if the player is on the specified surface.
Clicking a ping while being on another surface does nothing by itself except of sending an InputAction which then is responsible of raising on_player_clicked_gps_tag lua event where you can change surface and controller however you like.
That seems to be more trouble than it's worth. For now, I guess I'll just change the localized messages to print out surface name and position verbally instead of creating a GPS tag. But for reference, if I should try to add it later on:

Suppose there is a list of GPS tags that mark entity positions. The entities may be located on different surfaces, but clicking on a tag will only show the position if the player is on the same surface. So, in response to on_player_clicked_gps_tag I'd have to detach the character from the player, teleport the player to the specified position, and enter map view with player.open_map(position). However, I wouldn't notice when the player closes the map view again, so I couldn't teleport the player back to the original surface and reattach the character -- correct?
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”