Has tile been discovered? Is it currently visible?

Place to get help with not working mods / modding interface.
Post Reply
rolaca11
Burner Inserter
Burner Inserter
Posts: 10
Joined: Thu Dec 10, 2020 4:28 pm
Contact:

Has tile been discovered? Is it currently visible?

Post 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?

User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2904
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

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

Post 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
Last edited by darkfrei on Fri Dec 11, 2020 2:27 pm, edited 1 time in total.

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

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

Post 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?
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!

User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3700
Joined: Tue May 13, 2014 11:06 am
Contact:

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

Post by DaveMcW »

Visibility is only tracked in units of one chunk, you can't have partially visible chunks.

PFQNiet
Filter Inserter
Filter Inserter
Posts: 289
Joined: Sat Sep 05, 2020 7:48 pm
Contact:

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

Post by PFQNiet »

Pi-C wrote: ↑
Thu Dec 10, 2020 6:06 pm
Or 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.

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

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

Post 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. :-)
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!

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

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

Post 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!
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

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

Post 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".
Attachments
debug_tilevar4.png
debug_tilevar4.png (26.08 KiB) Viewed 3270 times
debug_tilevar3.jpg
debug_tilevar3.jpg (9.26 KiB) Viewed 3270 times
debug_tilevariation.png
debug_tilevariation.png (4.53 KiB) Viewed 3270 times
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: ζ—₯本θͺž, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

rolaca11
Burner Inserter
Burner Inserter
Posts: 10
Joined: Thu Dec 10, 2020 4:28 pm
Contact:

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

Post 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

rolaca11
Burner Inserter
Burner Inserter
Posts: 10
Joined: Thu Dec 10, 2020 4:28 pm
Contact:

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

Post 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

rolaca11
Burner Inserter
Burner Inserter
Posts: 10
Joined: Thu Dec 10, 2020 4:28 pm
Contact:

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

Post 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

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

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

Post 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?
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: ζ—₯本θͺž, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3700
Joined: Tue May 13, 2014 11:06 am
Contact:

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

Post by DaveMcW »

eradicator wrote: ↑
Fri Dec 11, 2020 1:15 am
Just 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.

rolaca11
Burner Inserter
Burner Inserter
Posts: 10
Joined: Thu Dec 10, 2020 4:28 pm
Contact:

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

Post by rolaca11 »

DaveMcW wrote: ↑
Fri Dec 11, 2020 1:35 am
eradicator wrote: ↑
Fri Dec 11, 2020 1:15 am
Just 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

rolaca11
Burner Inserter
Burner Inserter
Posts: 10
Joined: Thu Dec 10, 2020 4:28 pm
Contact:

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

Post 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
Last edited by rolaca11 on Fri Dec 11, 2020 11:14 pm, edited 1 time in total.

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

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

Post 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 am
Just 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.
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: ζ—₯本θͺž, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

rolaca11
Burner Inserter
Burner Inserter
Posts: 10
Joined: Thu Dec 10, 2020 4:28 pm
Contact:

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

Post 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 am
Just 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

Post Reply

Return to β€œModding help”