Page 1 of 1

LogisticCell function "is_in_construction_range" not working

Posted: Mon Feb 27, 2017 10:32 pm
by withers
Using the test code below, I'm trying to detect whether a specific entity is in construction range of a given cell. (entity_position is a local variable defined prior to the code fragment below)

Code: Select all

			if player.surface.find_logistic_network_by_position(entity_position, force) then -- is this entity in a logistic network?
				local nearest_cell = player.surface.find_logistic_network_by_position(entity_position, force).find_cell_closest_to(entity_position)
				if nearest_cell.is_in_construction_range(entity_position) then
					game.players[1].print (roster_entry.entity.name .. "found in range of a construction network.  Time to rebuild.....")				
				end
			end
It seems to be working correctly and printing the message if the entity is in LOGISTICS range (the orange zone), but not in CONSTRUCTION range (green zone). Am missing something, or is http://lua-api.factorio.com/latest/LuaL ... tion_range not working correctly?

Re: LogisticCell function "is_in_construction_range" not working

Posted: Mon Feb 27, 2017 11:23 pm
by posila
find_logistic_network_by_position will give you logistic network only if given position is in logistic range.

Re: LogisticCell function "is_in_construction_range" not working

Posted: Tue Feb 28, 2017 1:09 am
by withers
posila wrote:find_logistic_network_by_position will give you logistic network only if given position is in logistic range.
Ah ha! Knew it had to be one of those "answer right in front of you...." kind of things.

Re: LogisticCell function "is_in_construction_range" not working

Posted: Tue Feb 28, 2017 1:18 am
by Nexela
viewtopic.php?f=28&t=38195

I still declare it as api is not clear enough :)

However Added LuaSurface::find_logistic_networks_by_construction_area(..). has been implemented for .15

Re: LogisticCell function "is_in_construction_range" not working

Posted: Tue Feb 28, 2017 2:05 am
by Rseding91
Nexela wrote:viewtopic.php?f=28&t=38195

I still declare it as api is not clear enough :)

However Added LuaSurface::find_logistic_networks_by_construction_area(..). has been implemented for .15
viewtopic.php?f=28&t=38195#p235857