Page 1 of 1

Has tile been discovered? Is it currently visible?

Posted: Thu Dec 10, 2020 4:31 pm
by rolaca11
I'm trying to write a script that can take screenshots on the server-side. I can get the tiles that are at a given location, but I have no idea if they are visible to anyone, or if they have been discovered.

game.surfaces[1].getTile(x,y) will return the tile if it has been generated, but how can I know if the player has visited this tile ever? Or if it's visible to any radar/player?

Re: Has tile been discovered? Is it currently visible?

Posted: Thu Dec 10, 2020 4:59 pm
by darkfrei
rolaca11 wrote: Thu Dec 10, 2020 4:31 pm I'm trying to write a script that can take screenshots on the server-side. I can get the tiles that are at a given location, but I have no idea if they are visible to anyone, or if they have been discovered.

game.surfaces[1].getTile(x,y) will return the tile if it has been generated, but how can I know if the player has visited this tile ever? Or if it's visible to any radar/player?
Force:
https://lua-api.factorio.com/latest/Lua ... nk_charted
https://lua-api.factorio.com/latest/Lua ... nk_visible

Surface:
https://lua-api.factorio.com/latest/Lua ... _generated

Re: Has tile been discovered? Is it currently visible?

Posted: Thu Dec 10, 2020 6:06 pm
by Pi-C
When will this be true? If a chunk is completely visible, or if parts of a chunk are visible?

If I understand the question correctly, @rolaca11 was interested in whether a particular tile within a chunk is on the radar. According to the wiki, radars chart "an area of 7×7 chunks (224×224 tiles), centered on the chunk the radar occupies". This would mean that chunks are charted completely (3 chunks in each direction from the center). But how about mods that set radar.max_distance_of_sector_revealed to an even number? If I were to set it to 6, the radar would only cover 2.5 chunks in each direction from the center, so the far sides of the most distant chunks shouldn't be in range of the radar. Or is every chunk that's at least partially within the area of a radar scanned completely?

Re: Has tile been discovered? Is it currently visible?

Posted: Thu Dec 10, 2020 6:12 pm
by DaveMcW
Visibility is only tracked in units of one chunk, you can't have partially visible chunks.

Re: Has tile been discovered? Is it currently visible?

Posted: Thu Dec 10, 2020 6:13 pm
by PFQNiet
Pi-C wrote: Thu Dec 10, 2020 6:06 pmOr is every chunk that's at least partially within the area of a radar scanned completely?
This. That's why moving a radar over a chunk border moves the coverage area, but moving it within the chunk doesn't affect anything.

A position is visible if it is in a chunk that is currently revealed by a radar, player or spidertron. A position is charted if it has ever been revealed at some point.

Re: Has tile been discovered? Is it currently visible?

Posted: Thu Dec 10, 2020 6:26 pm
by Pi-C
DaveMcW wrote: Thu Dec 10, 2020 6:12 pm Visibility is only tracked in units of one chunk, you can't have partially visible chunks.
Interesting. So, radar.max_distance_of_sector_revealed will always be rounded up to the next odd integer? Last time I worked on my Maps mod, I've thought about dropping invisible short-vision radars that constantly keep tabs on a small area, so this would be good to know if I ever get to implementing that. :-)

Re: Has tile been discovered? Is it currently visible?

Posted: Thu Dec 10, 2020 6:34 pm
by Pi-C
PFQNiet wrote: Thu Dec 10, 2020 6:13 pm A position is visible if it is in a chunk that is currently revealed by a radar, player or spidertron. A position is charted if it has ever been revealed at some point.
OK, seems like I'll have to work on the logic for revealing areas in my mod again … in the future. Thanks for the info!

Re: Has tile been discovered? Is it currently visible?

Posted: Thu Dec 10, 2020 6:51 pm
by eradicator
rolaca11 wrote: Thu Dec 10, 2020 4:31 pm I'm trying to write a script that can take screenshots on the server-side.
Sidenote: As far as i am aware the api does not allow runtime access to tile variations. Thus by getting just the tile type you won't be able to get a correct representation of the map as the players see it.

All of these are just "grass-1".

Re: Has tile been discovered? Is it currently visible?

Posted: Thu Dec 10, 2020 7:56 pm
by rolaca11
darkfrei wrote: Thu Dec 10, 2020 4:59 pm
rolaca11 wrote: Thu Dec 10, 2020 4:31 pm I'm trying to write a script that can take screenshots on the server-side. I can get the tiles that are at a given location, but I have no idea if they are visible to anyone, or if they have been discovered.

game.surfaces[1].getTile(x,y) will return the tile if it has been generated, but how can I know if the player has visited this tile ever? Or if it's visible to any radar/player?
https://lua-api.factorio.com/latest/Lua ... nk_charted
https://lua-api.factorio.com/latest/Lua ... nk_visible
Thank you, really appreciate it. Seems like I completely misunderstood what this class is meant to represent

Re: Has tile been discovered? Is it currently visible?

Posted: Thu Dec 10, 2020 7:57 pm
by rolaca11
eradicator wrote: Thu Dec 10, 2020 6:51 pm
rolaca11 wrote: Thu Dec 10, 2020 4:31 pm I'm trying to write a script that can take screenshots on the server-side.
Sidenote: As far as i am aware the api does not allow runtime access to tile variations. Thus by getting just the tile type you won't be able to get a correct representation of the map as the players see it.

All of these are just "grass-1".
thanks, It doesn't matter to me rn though. I think grass-1 is good enough for me in the beginning at least

Re: Has tile been discovered? Is it currently visible?

Posted: Thu Dec 10, 2020 10:04 pm
by rolaca11
eradicator wrote: Thu Dec 10, 2020 6:51 pm
rolaca11 wrote: Thu Dec 10, 2020 4:31 pm I'm trying to write a script that can take screenshots on the server-side.
Sidenote: As far as i am aware the api does not allow runtime access to tile variations. Thus by getting just the tile type you won't be able to get a correct representation of the map as the players see it.

All of these are just "grass-1".
This turned out to be not true. in my output I see grass-1,2,3,4, etc and for other types as well

Re: Has tile been discovered? Is it currently visible?

Posted: Fri Dec 11, 2020 1:15 am
by eradicator
rolaca11 wrote: Thu Dec 10, 2020 10:04 pm This turned out to be not true.
The existance of variations was never in question. Just look at the graphic files. The only question is if you can access them at runtime, which i said i think you can't.
rolaca11 wrote: Thu Dec 10, 2020 10:04 pm in my output I see grass-1,2,3,4, etc and for other types as well
Those are different prototypes. Each prototype has several dozen variations.


Just to be sure... you do know about take_screenshot but are trying to do it on a per-tile basis because $reasons right?

Re: Has tile been discovered? Is it currently visible?

Posted: Fri Dec 11, 2020 1:35 am
by DaveMcW
eradicator wrote: Fri Dec 11, 2020 1:15 amJust to be sure... you do know about take_screenshot but are trying to do it on a per-tile basis because $reasons right?
They are trying to build a graphics driver for a headless server.

Re: Has tile been discovered? Is it currently visible?

Posted: Fri Dec 11, 2020 11:32 am
by rolaca11
DaveMcW wrote: Fri Dec 11, 2020 1:35 am
eradicator wrote: Fri Dec 11, 2020 1:15 amJust to be sure... you do know about take_screenshot but are trying to do it on a per-tile basis because $reasons right?
They are trying to build a graphics driver for a headless server.
exactly, thanks for the suggestion btw :D

I also tried running the non-headless version on a server, but handling virtual displays, without a GPU and all that is shady at best

Re: Has tile been discovered? Is it currently visible?

Posted: Fri Dec 11, 2020 9:44 pm
by rolaca11
eradicator wrote: Fri Dec 11, 2020 1:15 am
rolaca11 wrote: Thu Dec 10, 2020 10:04 pm This turned out to be not true.
The existance of variations was never in question. Just look at the graphic files. The only question is if you can access them at runtime, which i said i think you can't.
rolaca11 wrote: Thu Dec 10, 2020 10:04 pm in my output I see grass-1,2,3,4, etc and for other types as well
Those are different prototypes. Each prototype has several dozen variations.

The good news is, I can calculate how many tiles are in a bunch, the bad news is that it's a grind and not nice :D

UPDATE: It doesn't work

Re: Has tile been discovered? Is it currently visible?

Posted: Fri Dec 11, 2020 10:42 pm
by eradicator
rolaca11 wrote: Fri Dec 11, 2020 11:32 am
DaveMcW wrote: Fri Dec 11, 2020 1:35 am
eradicator wrote: Fri Dec 11, 2020 1:15 amJust to be sure... you do know about take_screenshot but are trying to do it on a per-tile basis because $reasons right?
They are trying to build a graphics driver for a headless server.
exactly, thanks for the suggestion btw :D

I also tried running the non-headless version on a server, but handling virtual displays, without a GPU and all that is shady at best
As expected then. Just making sure it's not another case of missing the blatantly obvious ;). On further thought you also don't get tile-transitions, thought those at least can probably be generated from prototype data.

Don't know what your setup is. Maybe you can find a hoster with cpus with integrated graphics? Or set up a machine that periodically downloads the map and does the screen-shotting in a seperate singleplayer instance.

Re: Has tile been discovered? Is it currently visible?

Posted: Fri Dec 11, 2020 11:15 pm
by rolaca11
eradicator wrote: Fri Dec 11, 2020 10:42 pm
rolaca11 wrote: Fri Dec 11, 2020 11:32 am
DaveMcW wrote: Fri Dec 11, 2020 1:35 am
eradicator wrote: Fri Dec 11, 2020 1:15 amJust to be sure... you do know about take_screenshot but are trying to do it on a per-tile basis because $reasons right?
They are trying to build a graphics driver for a headless server.
exactly, thanks for the suggestion btw :D

I also tried running the non-headless version on a server, but handling virtual displays, without a GPU and all that is shady at best
As expected then. Just making sure it's not another case of missing the blatantly obvious ;). On further thought you also don't get tile-transitions, thought those at least can probably be generated from prototype data.

Don't know what your setup is. Maybe you can find a hoster with cpus with integrated graphics? Or set up a machine that periodically downloads the map and does the screen-shotting in a seperate singleplayer instance.
I'm running servers on Digital Ocean. renting gpus is expensive af