Home   Help Search Login Register  

Author Topic: Returning roads with nearestObject  (Read 1670 times)

0 Members and 1 Guest are viewing this topic.

Offline Cheetah

  • Former Staff
  • ****
Returning roads with nearestObject
« 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.
Like missions? Help with Beta Testing! or take a look at the OFPEC Missions Depot for reviewed missions!

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Returning roads with nearestObject
« Reply #1 on: 28 May 2007, 17:12:25 »
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:

Offline Cheetah

  • Former Staff
  • ****
Re: Returning roads with nearestObject
« Reply #2 on: 28 May 2007, 17:15:20 »
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.
Like missions? Help with Beta Testing! or take a look at the OFPEC Missions Depot for reviewed missions!

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Returning roads with nearestObject
« Reply #3 on: 28 May 2007, 17:19:19 »
Yes, you can use object ids for nearestObject command, it works with most object types, but not with roads  ???

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re: Returning roads with nearestObject
« Reply #4 on: 28 May 2007, 19:31:36 »
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
I know a little about a lot, and a lot about a little.

Offline Cheetah

  • Former Staff
  • ****
Re: Returning roads with nearestObject
« Reply #5 on: 29 May 2007, 00:32:41 »
Hmm, I'll have to find another way to do it. Have a couple of ideas. Thanks gents.
Like missions? Help with Beta Testing! or take a look at the OFPEC Missions Depot for reviewed missions!

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: Returning roads with nearestObject
« Reply #6 on: 12 Jun 2007, 19:07:39 »
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:

Code: [Select]
(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.
urp!

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Returning roads with nearestObject
« Reply #7 on: 12 Jun 2007, 19:18:02 »
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.

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: Returning roads with nearestObject
« Reply #8 on: 12 Jun 2007, 20:09:19 »
Ah, yes! Use bounding box for the first pruning, and then string comparisons for whatever is left.
urp!