Jump to content
Sign in to follow this  
CarlGustaffa

How to obtain object classnames

Recommended Posts

Hi

How can I obtain the object classname for the closest object you're positioned at. What I want to achieve is a hint that says "house" if the closest object is a house.

I'm trying to destroy quite a few hayballs on a field so that artillery can use it without any object hazzle. I could go with destroying by theirs object id within a forEach, but I would like to know for the sake of curiosity smile_o.gif

Any tips?

Share this post


Link to post
Share on other sites

typeOf

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> hint format["%1",typeOf nearestobject getpos player]

Note: I believe the above command will always return the player object - it is an example only.

Share this post


Link to post
Share on other sites

The typeOf command was "sortof" the command I was looking for, but unfortunately it doesn't give me the information I need to destroy mapobjects by "class" (not objectname).

Looking at the provided example, I came up with something like this:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">hint format["0: %1\n1: %2", typeOf (getPos player nearobjects 10 select 0), typeOf (getPos player nearobjects 10 select 1)]

It picks up triggers as "EmptyDetector" and myself as "SoldierWMiner" if I play an engineer, and gamelogics as "Logic". Similarly, I get the lamps name instead of "streetlamp". But positioned close to a house it still reads i.e. "Land_budova1", while I'm looking for the output "house" which is what I use to destroy this building with.

For those hayballs, I'm actually getting zero output, and sometimes (even with a greater radius) I'm getting some weird division by zero error.

Btw, destroying hayballs per ID simply turns them from laying to standing with animation, although the collision detection is removed.

Are these different "classes" (not object names) listed somewhere? I'm awefully new at this btw.

Share this post


Link to post
Share on other sites
Are these different "classes" (not object names) listed somewhere? I'm awefully new at this btw.

This might get you into the right direction: CfgVehicles

Share this post


Link to post
Share on other sites

Well, I've now ried most of the "higher levelhierarchy names" (including "All" which gave lots of funky crashaction smile_o.gif), but nothing appears to take care of those haystacks.

Similarly, I couldn't find "streetlamp" in that list, which name I use in a similar fashion.

The area I'm talking about is SSE pf Mercalillo on Sahrani. In case you'd like to demolish some hay tounge2.gif

I can place a "Street-Objects/Lamp 2" from the editor (with the editor upgrade), but the name "Lamp" is nowhere to be found within the CfgVehicles list.

Edit: Can't use countType as it needs typeinfo. It is this typeinfo/classname I'm trying for obtain for certain objects.

Share this post


Link to post
Share on other sites

Like many "simple" map objects, the haybails have no class. (they spend their Saturday nights in the park wearing tuxedo t-shirts, drinking cheap cask wine straight from the box). typeOf will not return anything anything for such classless objects.

You could reference each individual haybail using it's object ID (boring!).

Or create a list of all objects in a given area, then use something like Kronzky's new string library to remove the ID number and colon (:), then check if each object's model is a haybail (seno_balik.p3d?). This will be slower but much more flexible and "kewl".

Streetlights return a class found by typeOf (Land_lampa_sidl), which also happens to be their model name.

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  

×