inverted search limit filter

Place to get help with not working mods / modding interface.
spacedestructor
Inserter
Inserter
Posts: 20
Joined: Sat Aug 19, 2017 6:06 pm
Contact:

inverted search limit filter

Post by spacedestructor »

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.
User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3743
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: inverted search limit filter

Post by DaveMcW »

The radius and limit filters cannot be inverted.

I would search the entire surface, then calculate the radius yourself using triangles: a² + b² = c².
spacedestructor
Inserter
Inserter
Posts: 20
Joined: Sat Aug 19, 2017 6:06 pm
Contact:

Re: inverted search limit filter

Post by spacedestructor »

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².
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.
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?
User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3743
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: inverted search limit filter

Post by DaveMcW »

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) )
spacedestructor
Inserter
Inserter
Posts: 20
Joined: Sat Aug 19, 2017 6:06 pm
Contact:

Re: inverted search limit filter

Post by spacedestructor »

DaveMcW wrote: Wed Jan 04, 2023 2:25 am

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) )
Thanks a lot for the help!
Post Reply

Return to “Modding help”