Page 1 of 1

Unstable chunk/tile count?

Posted: Fri Oct 14, 2022 9:13 pm
by Mskvaer
I have started to write my first mod. This will make a simplified but printable map - when one needs a world overview.

The mod is at version 0.1.3 (more of a POC/test) and can write lists/counts of chunks or tiles. Although I reload the same small map and give my "/dmpmap" the count of chunks varies from testrun to testrun (the character stands still). The same if I generate a fresh map

Code: Select all

outer bounds-11,10,-10,9
417 chunks counted
outer bounds-11,10,-10,9
419 chunks counted
(bounds are LowX,HighX,LowY,HighY. Tilecount == chunkcount*1024, of course)

I suspect it has something to do with the biter-movements - or what?

Second question - what attribute is there that decides if the chunk is visible, assuming there are chunks (active or not) that are "black"?

Ah, well, lets see what the outline of chunks looks like - the next piece of code I'll try and write. ASCII-art for the while being.
(edit: typos fixed)

Re: Unstable chunk/tile count?

Posted: Sat Oct 15, 2022 12:04 am
by Silari
The game generates chunks as they are needed - either because a player explored them, pollution reached them, a script asked for it to be generated, etc. It generally generates a few chunks beyond what a player sees. Map generation also uses a scheduling system so depending on what tick you call it on there may be more or less chunks finished generating.

Chunk visibility is stored per force, and can be accessed via a couple of the commands in LUAForce, like is_chunk_visible. It's possible for forces to share their chart data with each other. Generally the only force you're going to care about is 'player'.

Re: Unstable chunk/tile count?

Posted: Sat Oct 15, 2022 8:07 pm
by Mskvaer
Thank you for the hint. "is_visible" means showing live to the player (always 25) in the map - or any radar (50 each, unless overlapping of course)

So, still looking for something that indicates if the chunk is shown black or rendered in the map view. Maybe my question was unclear.

Background info - extract of the code scanning chunks.

Code: Select all

local world = game.get_surface("nauvis")
local player = world.find_entities_filtered { name="character" }
local myforce = player[1].force
local CC, HC = 0, 0
for chunk in world.get_chunks() do
	CC = CC + 1
	if not myforce.is_chunk_visible("nauvis", {chunk.x, chunk.y})
	  then HC = HC + 1
		end
end
write_map_line(CC .. " chunks counted, " .. HC .. " hidden")
(write_map_line() is just outputting text for now)

Re: Unstable chunk/tile count?

Posted: Sat Oct 15, 2022 8:47 pm
by Silari
Mskvaer wrote:
Sat Oct 15, 2022 8:07 pm
Thank you for the hint. "is_visible" means showing live to the player (always 25) in the map - or any radar (50 each, unless overlapping of course)
Ooops copied the wrong one. It's the command above that one that checks if a force has charted a chunk: https://lua-api.factorio.com/latest/Lua ... nk_charted

If it's false, the chunk will be black in map view.

[Solved] Unstable chunk/tile count?

Posted: Sun Oct 16, 2022 7:51 pm
by Mskvaer
OK, thanks. So now the first protope of an initial attempt of a POC produces

Code: Select all

262 charted chunks counted
740352
Player at X223.1 Y-694.5
            ¤¤¤¤¤
          ¤¤¤¤¤¤¤
         ¤¤¤¤¤¤¤¤
        ¤¤¤¤¤¤¤¤¤
        ¤¤¤¤¤¤¤¤¤
     ¤¤¤¤¤¤¤¤¤¤¤¤
    ¤¤¤¤¤¤¤¤¤¤¤  
 ¤¤¤¤¤¤¤¤¤¤¤¤¤¤  
 ¤¤¤¤¤¤¤¤¤¤¤¤¤¤  
 ¤¤¤¤¤¤¤¤¤¤¤¤¤¤  
 ¤¤¤¤¤¤¤¤¤¤¤¤¤¤  
 ¤¤¤¤¤¤¤¤¤¤¤¤¤¤  
¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤  
¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤  
¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤  
¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤  
¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤  
 ¤¤¤¤¤¤¤¤¤¤¤¤¤¤  
 ¤¤¤¤¤¤¤¤¤¤¤¤¤¤  
 ¤¤¤¤¤¤¤¤¤¤¤¤¤¤  
 ¤¤¤¤¤¤¤¤¤¤¤¤¤¤  
:) :) :)