I hope this is the correct place for me to ask this question,
i have recently come across a situation thats not documented in the official Factorio api documentation and so i would like to ask if anyone in the community has an answer for me.
I entered a situation where i search in a given radius for any entities owned by the player that are outside the radius (searching in a radius for things outside of it? not sure if this is the correct choice of words).
I know that inverting the search filter will apply to all filters and for something like the force the entity should be owned by this is rather obvious but what happens if i apply a limit filter to the search. will it return with an example limit of 5 all except the first 5 matches?
for the desired result the behaviour of the limit doesnt matter in the end but i would still like to know, so i can maybe get a better fine control over the results.
inverted search limit filter
-
- Inserter
- Posts: 20
- Joined: Sat Aug 19, 2017 6:06 pm
- Contact:
Re: inverted search limit filter
The radius and limit filters cannot be inverted.
I would search the entire surface, then calculate the radius yourself using triangles: a² + b² = c².
I would search the entire surface, then calculate the radius yourself using triangles: a² + b² = c².
-
- Inserter
- Posts: 20
- Joined: Sat Aug 19, 2017 6:06 pm
- Contact:
Re: inverted search limit filter
Thanks for the info that the radius cant be inverted, i wasnt aware of this and would otherwise have used the inverted filter with radius assuming i get anything outside of the radius.DaveMcW wrote: Wed Jan 04, 2023 1:46 am The radius and limit filters cannot be inverted.
I would search the entire surface, then calculate the radius yourself using triangles: a² + b² = c².
The radius it self isnt really that important to me, i just want to filter entities by if they are owned by the play and far enough from the player so i can perform the action i want to do.
I hope im not asking for too much but if your so kind to already give me the math to calculate the radius my self, how would i calculate the distance between 2 co-ordinates in factorio?
Re: inverted search limit filter
Code: Select all
/c
player = game.player
entity = game.player.selected
game.print( "Distance between " .. entity.name .. " and " .. player.name .. " is: " .. math.sqrt((entity.position.x - player.position.x)^2 + (entity.position.y - player.position.y)^2) )
-
- Inserter
- Posts: 20
- Joined: Sat Aug 19, 2017 6:06 pm
- Contact:
Re: inverted search limit filter
Thanks a lot for the help!DaveMcW wrote: Wed Jan 04, 2023 2:25 amCode: Select all
/c player = game.player entity = game.player.selected game.print( "Distance between " .. entity.name .. " and " .. player.name .. " is: " .. math.sqrt((entity.position.x - player.position.x)^2 + (entity.position.y - player.position.y)^2) )