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