Capt Childs 178 Posted July 10, 2015 I'm trying to get Arma to return the nearest location from a specific set of locations. I can achieve this from a single location type, but I need to get a return for the nearest type of a specific selection. _loc = text nearestLocation [position player,"NameVillage"]; This works for my needs, looking for a single location type. I want to get a return on the nearest of a selection something like: _loc = text nearestLocations [position player,"Airport","NameLocal","NameVillage","NameCity","NameCityCapital","NameMarine"]; What am I doing wrong? I appeal to those cleverer than I for help! :confused: Share this post Link to post Share on other sites
Greenfist 1863 Posted July 10, 2015 (edited) Nearestlocations returns the nearest of all types as the first element in the array. So: _loc = (nearestLocations [ position player, ["Airport","NameLocal","NameVillage","NameCity","NameCityCapital","NameMarine"],20000]) select 0; Edited July 10, 2015 by Greenfist Share this post Link to post Share on other sites
Capt Childs 178 Posted July 17, 2015 How do I get this to return a text response, as per my examples? I can only get co-ords coming back with the above. Share this post Link to post Share on other sites
Greenfist 1863 Posted July 17, 2015 With text, just like in your example: _loc = text (nearestLocations [ position player, ["Airport", "NameLocal", "NameVillage", "NameCity", "NameCityCapital","NameMarine"],20000] select 0); Share this post Link to post Share on other sites
killzone_kid 1333 Posted July 17, 2015 How do I get this to return a text response, as per my examples? I can only get co-ords coming back with the above. Really? Nearestlocations returns the nearest of all types as the first element in the array.So: _loc = text ((nearestLocations [position player, ["Airport", "NameLocal", "NameVillage", "NameCity", "NameCityCapital", "NameMarine"], 20000]) select 0); Share this post Link to post Share on other sites
Capt Childs 178 Posted July 17, 2015 I swear I tried this!! Clearly I was missing something however, as it "now works". ;) Thanks guys. Share this post Link to post Share on other sites
NecorB 1 Posted October 6, 2016 (edited) From what code of the above did you get coords [x,y]? _pos = getArray (configfile >> "CfgWorlds" >> "Altis" >> "Names" >> "TonosBay" >> "position"); // Manual test. Not very useful... Outputs: [x,y] (that I can use for setPos for example) _nearbyLocations = nearestLocations [position player, ["NameMarine"], 500]; Outputs (for me at least): [Location NameMarine At 11988, 22986] (but I can't figure out how to use it. I can see the numbers of the location but not access them. Any attempts of select element either gives me the same output or gives error Config entry expected.) _loc = (nearestLocations [ position player, ["Airport","NameLocal","NameVillage","NameCity","NameCityCapital","NameMarine"],20000]) select 0; Outputs: [Location NameMarine At 11988, 22986] (Same as above (because their is only one element?)). First example is not very dynamic...would have liked to be able to use the position in [x,y] and type from nearestLocation (that I can hint on screen but not use) for scripting but don't see what I'm missing. Edit; Sometimes the easy obstacles are the hardest. A simple getPos on _nearbyLocations (or _loc) did the trick. I guess I never tried it before because the output from nearestLocations looked so weird. But all is now good. Edited October 6, 2016 by NecorB Share this post Link to post Share on other sites
killzone_kid 1333 Posted October 6, 2016 The result is array of locations. Pick one then use locationPosition to get position. For example: _nearbyLocations = nearestLocations [position player, ["NameMarine"], 500]; _pos = locationPosition (_nearbyLocations select 0); hint str _pos; It even has example on BIKI! https://community.bistudio.com/wiki/locationPosition 1 Share this post Link to post Share on other sites
NecorB 1 Posted October 6, 2016 The result is array of locations. Pick one then use locationPosition to get position. For example: _nearbyLocations = nearestLocations [position player, ["NameMarine"], 500]; _pos = locationPosition (_nearbyLocations select 0); hint str _pos; It even has example on BIKI! https://community.bistudio.com/wiki/locationPosition Yes. I must have looked at that example page 50 times by now (plus many other, inc your (if it really is you) array tutorials. Examples takes time for a noob to interpret though. I knew the nearestLocations returned Array of Locations, just took until just now for the penny to drop as to what that meant and how to use it. I also found this working. _nearbyLocations = (nearestLocations [position player, ["NameMarine"], 500]) select 0; // Nearest location of type to position (player). RETURN: (Class?)Array of location(s) _locName = text _nearbyLocations; // Not mine, just don't remember where I found it _locPos = position _nearbyLocations; // Not mine, just don't remember where I found it _locType = type _nearbyLocations; // Not mine, just don't remember where I found it Which does the exact same your code does, only yours look better. For now I will go with my example because it's somewhat easier to follow (for the untrained eye) but later I will clean it up. Now I have what I need though (for now :) ). Next is learning the switch i guess. Many thanks. Share this post Link to post Share on other sites