LogisticCell function "is_in_construction_range" not working

Place to get help with not working mods / modding interface.
User avatar
withers
Fast Inserter
Fast Inserter
Posts: 125
Joined: Fri Apr 08, 2016 4:54 pm
Contact:

LogisticCell function "is_in_construction_range" not working

Post 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?
posila
Former Staff
Former Staff
Posts: 5448
Joined: Thu Jun 11, 2015 1:35 pm
Contact:

Re: LogisticCell function "is_in_construction_range" not working

Post by posila »

find_logistic_network_by_position will give you logistic network only if given position is in logistic range.
User avatar
withers
Fast Inserter
Fast Inserter
Posts: 125
Joined: Fri Apr 08, 2016 4:54 pm
Contact:

Re: LogisticCell function "is_in_construction_range" not working

Post 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.
Nexela
Smart Inserter
Smart Inserter
Posts: 1828
Joined: Wed May 25, 2016 11:09 am
Contact:

Re: LogisticCell function "is_in_construction_range" not working

Post 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
Rseding91
Factorio Staff
Factorio Staff
Posts: 16442
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: LogisticCell function "is_in_construction_range" not working

Post 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
If you want to get ahold of me I'm almost always on Discord.
Post Reply

Return to “Modding help”