How to test if two logistics networks are the same?

Place to get help with not working mods / modding interface.
Post Reply
whitecold
Inserter
Inserter
Posts: 46
Joined: Fri May 19, 2017 6:48 am
Contact:

How to test if two logistics networks are the same?

Post by whitecold »

I am trying to match various entities if they are in the same logistics network
I am first saving entities into a table by the logistics network gotten by find_logistic_network_by_position

Code: Select all

local parent = surface.find_logistic_network_by_position(combinator.position, combinator.force)
	if parent ~= nil then
		if networks[parent] == nil then
			networks[parent] = {combinators = {combinator}, signals={ } }
			game.print("Started")
		else
			table.insert(networks[parent]["combinators"], combinator)
			game.print("Inserted")
		end
	end
Later I want to match those by checking if the key exists in the table, getting my keys from find_logistic_networks_by_construction_area
Unfortunately this always seems to come up nil. What am I doing wrong here?

Code: Select all

local network_candidate = surface.find_logistic_networks_by_construction_area(entity.position, entity.force)
	for i, candidate in pairs(network_candidate) do
		--sort ghosts to valid logistics networks.
		if networks[candidate] ~= nil then
			local dict = ent.ghost_prototype.items_to_place_this	
			for key,value in pairs(dict) do
				if networks[candidate]["signals"][key] == nil then
					networks[candidate]["signals"][key] = 1
				else
					networks[candidate]["signals"][key] = networks[candidate]["signals"][key] + 1
				end
			end
		end
	end 

Post Reply

Return to “Modding help”