OFPEC Forum
Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting General => Topic started by: Cheetah on 28 May 2007, 16:58:45
-
Should be simply, but can't find the classnames of a road. So I don't know how to put the nearestObject(s) into action.
I'd like to use it to make a civilian run to the nearest road, dynamically.
-
Was trying to find the types with:
road = position player nearestObject 462870; hint format["%1", typeOf road]
using different road segment ids on the map. Sadly nearestObject fails miserably with road ids :blink:
-
Thought that you can't use the object ID? Might explain why it's not working. Anyway, I couldn't find a list of roads / streets anywhere.
-
Yes, you can use object ids for nearestObject command, it works with most object types, but not with roads ???
-
Hmmm.........roads don't have classnames, they are embedded into the .wrp file and don't need a classname, consequently there are no configs for roads, unless you count bridges.
Planck
-
Hmm, I'll have to find another way to do it. Have a couple of ideas. Thanks gents.
-
Before doing anything use Mandoble's snippet in various locations to get the name string for various road objects, to see if they have any part of their name in common that is unique to roads. If there is then:
(nearestObjects [player,[], 50]) - ((getPos player) nearObjects 50)
Returns an array of objects within 50m of the player that have no class, including things like roads and trees.
Then use Kronzky's string functions to scan the string name of each object for the common name part.
The only problem with this is the Kronzky's string functions cause very bad resource sucking lag, and searching 50 strings for a substring would be crazy. You would have to manually insert some pauses in his functions.
-
May be you can check for those returned objects which bounding box has a quite low height/width or height/length ratio. If that works, you would not need to use any string comparison.
-
Ah, yes! Use bounding box for the first pruning, and then string comparisons for whatever is left.