dmarkwick 261 Posted April 17, 2008 In my bid to persuade birds to live in trees, I don't think nearestObject is capable of finding map trees. They're not defined in cfgVehicles and so the command is not (according to the docs) suitable for the task. So, how can I find a tree of a specific type? Share this post Link to post Share on other sites
vova _fox 0 Posted April 17, 2008 ahahahaha list=nearestObjects [position player,[], 100] Share this post Link to post Share on other sites
loyalguard 15 Posted April 17, 2008 DM- I think the main issue is similar to this thread that you, vova, fasad and others posted in... http://www.flashpoint1985.com/cgi-bin....tobject ...and in another thread relevant to the topic also with posts by fasad: http://www.flashpoint1985.com/cgi-bin....tobject Share this post Link to post Share on other sites
lecholas 2 Posted April 17, 2008 I had a similar problem - I wanted to rull out roads from an array of classless objects. It is possible but the solution is not elegant. In the array of classless objects you have objects' ids and p3ds' names. For every object you have to get rid of the id, convert p3d's name to a string and check if it matches an element form an array with names of trees' p3d (you have to make such an array manually). Would be helpful if all objects' p3d names had tags (eg. road_version1.p3d, tree_small_oak1.p3d, tree_small_pine.p3d) this way you could check only if the tags are correct. Share this post Link to post Share on other sites
dmarkwick 261 Posted April 17, 2008 LOL, yeah I do remember discussing this topic a while back, but I've seen a few threads closed for being "too old" so I just started a new one Well it looks like there is a solution, albeit as lecholas said an inelegant one. Luckily for me the applications doesn't need to be speedy or real-time or anything like that, it's just periodic trigger placements. Anyone able to post up some examples of string conversion code from a returned list? Share this post Link to post Share on other sites
kronzky 5 Posted April 18, 2008 Actually, with the newly expanded String Library it's fairly straightforward to do. You first convert the object array that nearestObjects returns into an array of strings, and then you use the function KRON_getArgRev to find any occurrences of the types of trees you're looking for. Unfortunately you will have to assemble the list of tree names yourself - there is no automated way of determining what is a tree and what isn't. But luckily the names are somewhat self-explanatory. Here's an example that lists any of the three palm trees within a 20 meter radius. I'm sure you'll be able to tweak it to your specific needs.<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">nul=[] execVM "KRON_STRINGS.sqf"; // load the string library _radius=20; // how far you want to look for trees _trees=[" palm_01.p3d"," palm_02.p3d"," palm_03.p3d"]; // the names of trees while {true} do {  _objlist = nearestObjects [player,[],_radius]; // get every object within the specified radius  _strlist = []; {_strlist = _strlist + [str(_x)]}forEach _objlist; // convert those array elements into strings  // check for every type of tree  {   _fnd=[_strlist,_x] call KRON_getArgRev; // does the element contain the tree name?   if (_fnd!="") then { // if it does, the object id is returned as a string    _objId=parseNumber(_fnd); // convert it to a number    _obj=position player nearestObject _objId; // and get the proper object    player sidechat format["%1 found as object# %2 (%3)",_x,_objId,getPos _obj]; // show off what we found;)    };  }forEach _trees;  sleep 1; }; You can also download a demo mission from here. Share this post Link to post Share on other sites
dmarkwick 261 Posted April 18, 2008 Thanks for that Kronzky, I'm pretty sure I can bend that to my needs. In fact it also resurrects an older idea I had (forest fires) if I can figure out how to destroy map trees in code. Looks like you've been more helpful to me than I've been to you lately *edit* Nothing available at your first link there K, but I got the sample mission, does that hold all that I need? Share this post Link to post Share on other sites
kronzky 5 Posted April 18, 2008 Nothing available at your first link there K, but I got the sample mission, does that hold all that I need? The first link goes to the string library itself, but you don't need to download that separately, as everything is included already in the demo mission. Share this post Link to post Share on other sites
dmarkwick 261 Posted April 18, 2008 Rgr dat Can I include your library in my addons? (Credits etc) Share this post Link to post Share on other sites
kronzky 5 Posted April 18, 2008 Can I include your library in my addons? (Credits etc) Of course! That's what they're for - to be used... Share this post Link to post Share on other sites