Jump to content
Sign in to follow this  
smacker909

Difference between nearestLocations and bis_fnc_locations

Recommended Posts

So, me, being !(expert scripter) did read the wiki and did notice one is function and one is a command.. but didn't see any other noticeable difference. The wiki didn't say why it's better to use one over the other. So maybe a better question is, what is the benefit of using a function over a command or vise verse.

Edited by smacker909

Share this post


Link to post
Share on other sites

The two are actually very different - the only common trait is that both have something to do with locations. I can not think of a scenario when you could equally use both. Choosing the most suitable one depends entirely on what you are trying to achieve:

nearestLocation is used to return locations of a chosen type in an area.

BIS_fnc_locations is used to create and "register" new locations or register existing ones. This registering is really just creating and setting a bunch of variables, which are required by BI Warfare, Ambient Civilians, etc modules. These variables might be useful for some other purposes.

Edited by ceeeb

Share this post


Link to post
Share on other sites

Unfortunately the wiki does not shed more light on these two different commands/functions:

AFAIK these two are very different in the actual result:

nearestLocations returns Locations!!!

BIS_fnc_locations returns Objects!!! that are also like Locations but you cannot use functions like "direction" or "size" on them. At least for me this resulted in error messages like "got Object, expected Location".

I would prefer to use nearestLocations but then you cannot use setVariables on the Locations (even if the wiki on setVariable tells you otherwise).

Does anyone know more about that?

EDIT: Actually I wish Locations could accept NameSpace Variables!!! That 'd be the best of all right now!!! Thank You!!! :bounce3:

Edited by rosentorf

Share this post


Link to post
Share on other sites

I need in my current work variables set to locations, so tested such code in init.sqf:

_sec = createLocation ["Name", (position player), 2, 2];

_sec setVariable ["Var",123];

_var = _sec getVariable "Var";

hint (str _var);

and got expected hint "123". Same with this:

_sec = createLocation ["Name", (position player), 2, 2];

_nL = nearestLocations [position player, ["Name"], 10];

_sec = _nL select 0;

_sec setVariable ["Var",123];

_var = _sec getVariable "Var";

hint (str _var);

So you can use setVariable/getvariable with locations, also if retrieved via nearestLocations...

Share this post


Link to post
Share on other sites
So you can use setVariable/getvariable with locations, also if retrieved via nearestLocations...

Wow, that did not work for me two month ago...have to try it out!!!

Edit: Unless,... I need to do that with predefined locations on the map: "CityCenter" or "StrongPointArea" and such.

Share this post


Link to post
Share on other sites
Edit: Unless,... I need to do that with predefined locations on the map: "CityCenter" or "StrongPointArea" and such.

Predefined of any type not tested. If there is any difference, you always can create new location over predefined, of same shape and radius, of any type, and then refer to that location instead of predefined.

Share this post


Link to post
Share on other sites

In a first test I could get set-/getVariable to work with a location made with createLocation. However I did not work with the predefined locations. Now, to test I used the mission that I am making right now so I have some things initialized and stuff, but I think the test was basically using your code in the init.sqf and tested predefined and created locations basically next to each other.

Predefined of any type not tested. If there is any difference, you always can create new location over predefined, of same shape and radius, of any type, and then refer to that location instead of predefined.

Good Point! I guess I will have to adjust my mission to have a dedicated set of locations so I can add attributes to them. Thanks!

It seems weird why there is a difference, seemingly.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×