Make count_tiles and find_tiles filtered

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

Make count_tiles and find_tiles filtered

Post by darkfrei »

Hi all!

It would be good to search tiles with some fast function. For example we have

Code: Select all

surface.count_entities_filtered{area=…, position=…, name=…, type=…, force=…, limit=…}
with parameters

Code: Select all

surface.count_entities_filtered{area=area, force=player_force, limit=1}
, it works much better then code like

Code: Select all

function find_first_good_tile_in_chunk(chunk, surface, good_tiles_list)
	for y = (chunk.y*32), (chunk.y*32+31) do
		for x = (chunk.x*32), (chunk.x*32+31) do
			local tile = surface.get_tile(x, y)
			for i, tile_name in pairs (good_tiles_list) do
				if tile and (tile.name == tile_name) then
					return true
				end
			end
		end
	end
	return false
end
Reference mod: https://mods.factorio.com/mods/darkfrei ... mptyChunks
Performance was got from https://mods.factorio.com/mods/darkfrei ... sion/21503 - first tile searching needs twice (in this case) more time then first entity searching with force in higher quantity of chunks.
User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2905
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: Make count_tiles and find_tiles filtered

Post by darkfrei »

Or it will be good to have tile.force by all player placed tiles, if it possible.
Rseding91
Factorio Staff
Factorio Staff
Posts: 14912
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Make count_tiles and find_tiles filtered

Post by Rseding91 »

darkfrei wrote:Or it will be good to have tile.force by all player placed tiles, if it possible.
There exists no such property that the game could expose. All tiles are forceless and owned by no one.
If you want to get ahold of me I'm almost always on Discord.
User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2905
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: Make count_tiles and find_tiles filtered

Post by darkfrei »

Rseding91 wrote:There exists no such property that the game could expose. All tiles are forceless and owned by no one.
There must be one parameter - can this tile be removed by the player or not. Or was this tile place by player or was generated. I can remove concrete, but I can't remove landfill. Why?
Post Reply

Return to “Implemented mod requests”