Jump to content
MrCrazyDude115

[Question] AddAction to Terrain Object?

Recommended Posts

Hey guys!

 

I know I post a lot of questions here, hope I'm not bothering anyone!

 

Basically, I'm using this script to add an ACE action to a specific classname.

 

["CUP_clutter_mochomurka", 0, ["ACE_MainActions"], _gatherMushrooms] call ace_interact_menu_fnc_addActionToClass;

 

This works fine, but only if I manually place down or spawn the classname as an object. How can I create a loop which checks terrain objects for this classname, and adds the action to all of them?

 

Any help will be greatly appreciated, thank you!

Share this post


Link to post
Share on other sites

Have you tried adding a regular (non-class specific) interaction to objects returned by the nearestTerrainObjects command? 

Don't have my PC here so I can't test it right now.

Share this post


Link to post
Share on other sites
3 hours ago, runy888 said:

Have you tried adding a regular (non-class specific) interaction to objects returned by the nearestTerrainObjects command? 

Don't have my PC here so I can't test it right now.

 

How can I do that?

Share this post


Link to post
Share on other sites
5 hours ago, MrCrazyDude115 said:

How can I do that?


To elaborate on my suggestion, here is what I meant:

 

Quote

// First create your ACE interaction here
private _gatherMushrooms = XYZ...

// Now you make an array with ALL terrain objects on the map 
private _terrainObjects = nearestTerrainObjects [[worldSize / 2, worldSize /2, 0], [], worldsize / 2];


// Now go through every single entry in that array
{
  // Only apply code if the object is of the type that you are looking for 
  if (typeOf _x == "CUP_clutter_mochomurka") then 
  {
    // Now you add the ACE interaction to the object 
    [_x, 0, ["ACE_MainActions"], _gatherMushrooms] call ace_interact_menu_fnc_addActionToObject;
  };
};

 

Note that this code is untested and I guarantee no success or absence of harm when executing it 😛

  • Thanks 1

Share this post


Link to post
Share on other sites
6 hours ago, runy888 said:


To elaborate on my suggestion, here is what I meant:

 

 

Note that this code is untested and I guarantee no success or absence of harm when executing it 😛

Gonna try this now!

 

EDIT: NO luck. 😞

Share this post


Link to post
Share on other sites
10 hours ago, MrCrazyDude115 said:

Gonna try this now!

 

EDIT: NO luck. 😞

Ehrm that's not exactly how you bugfix. 

Look at any error messages and try to cut down the code until you find the point that causes problems. At the very least, describe what exactly doesn't work.

Share this post


Link to post
Share on other sites
4 hours ago, runy888 said:

Ehrm that's not exactly how you bugfix. 

Look at any error messages and try to cut down the code until you find the point that causes problems. At the very least, describe what exactly doesn't work.

 

No errors, just doesn't work. I tried also using getModelInfo and used the .p3d instead of the class but it didn't work either.

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

×