Question about distance and path

Place to get help with not working mods / modding interface.
catarix7
Burner Inserter
Burner Inserter
Posts: 5
Joined: Wed Apr 06, 2016 10:58 pm
Contact:

Question about distance and path

Post by catarix7 »

Hi all.
i want to put entity via script on some random point on circle with distance 100 from players base. i used the command to check the spot.

Code: Select all

if (game.get_surface(1).can_place_entity{name = "big-biter", position = {Fin_x, Fin_y}}) then
i would like to know
1. how i can check distance from nearest player building? i found parameter min_player_base_distance in map-setting but do not understand how it works.
2. how i can check that there is a way from my random point to players base (or center of a map). i founded pathfinder in Misanthrope mode but i would prefer to use basic game function.
thank you in advance
User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3749
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: Question about distance and path

Post by DaveMcW »

There is no built in function to locate the player's base or check distance from it. Certainly not min_player_base_distance.

You could implement your own by using some geometry. Pick a direction from the center of the map, use find_entities_filtered in that direction, and find the building farthest from the center. Then add 100 to get your spawn point.

The API does not include a pathfinder function, which is why Misanthrope had to implement its own.
Post Reply

Return to “Modding help”