Jump to content
MrCrazyDude115

[Help] AddAction to Every Type of Object?

Recommended Posts

Hey guys!

 

So I'm trying to make it so that everything with a specific classname will have an AddAction added onto it.

 

This is the code I have so far, but it isn't working. What am I doing wrong?

 

//Gather Mushrooms
act_gatherMushrooms = player addAction[
"Gather Mushrooms",
'
	private["_trg"];
	_trg = cursorTarget;

	player playMoveNow "UnconsciousMedicFromUnarmed";
	player playMove "UnconsciousMedicOut";
	sleep 4;
	player addItem "kss_mushrooms";
    hint "Gathered Mushrooms";

',
"",
10,
true,
true,
"",
'
	_show = false;
	_trg = cursorTarget;
	if ( (typeOf _trg) in ["fern_boletus_group", "fern_amanita_single", "CUP_clutter_mochomurka"] ) then {
		_show = true;
	};
	_show
'
];

I also have another question, what if instead of making it an addAction, I want to make it that thing that pops up and asks you to hold down space. Example is the "Search" feature in Ravage. What If I want to implement that instead of the addAction?

 

Any help will be appreciated!

Share this post


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

private["_trg"];

_trg = cursorTarget;

->

private _trg = cursorTarget;

 

4 hours ago, MrCrazyDude115 said:

'
    _show = false;
    _trg = cursorTarget;
    if ( (typeOf _trg) in ["fern_boletus_group", "fern_amanita_single", "CUP_clutter_mochomurka"] ) then {
        _show = true;
    };
    _show
'

->

'(typeOf cursorTarget) in ["fern_boletus_group", "fern_amanita_single", "CUP_clutter_mochomurka"]'

 

Did you keep in mind that the "in" command is case-sensitive and that the classnames need to match exactly?

Also aren't these terrain objects? cursorTarget doesn't return terrain objects, I guess you wanted cursorObject instead maybe?

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites
1 minute ago, Dedmen said:

->


private _trg = cursorTarget;

 

->


'(typeOf cursorTarget) in ["fern_boletus_group", "fern_amanita_single", "CUP_clutter_mochomurka"]'

 

Did you keep in mind that the "in" command is case-sensitive and that the classnames need to match exactly?

Also aren't these terrain objects? cursorTarget doesn't return terrain objects, I guess you wanted cursorObject instead maybe?

 

Yes, they're terrain objects. Should I use cursorObject instead?

Share this post


Link to post
Share on other sites

Hiho, 

 

Exactly the type of feature that i have spend my recent nights tinkering with! 

 

Use the cursorObject command and get the model  (.p3d) from the object.

_model = (getModelInfo cursorObject) select 0;

do not work with classnames when comparing your (map) object against an array. 

 

You can use the same command to look at map objects and return their model name, if you do not want to dig into the config. 

I learned recently that most map objects will not return a classname. (thanks yuki:)) 

 

I am working on a similar gathering system (e.G. Picking apples from apple trees, pumpkins from pumpkin plants,.. ) and will extend my system with scripts to gather berries, roots, mushrooms,... 

from map objects. 

 

I have opted out to use addactions/holdactions or a looped check to assign these gathering actions to objects. 

My current solution is a hotkey based system that executes different gathering scripts based on your cursorobject (look at an apple tree , press hotkey and gather apples). I think this is a good approach as it doesnt require loops to constantly run in the background. Code is only executed upon request. 

 

Also, you should consider to add a fallback option in case you do not have space in your inventory, so instead the loot will be dropped on the ground nearby. (else its lost if you do not have space). 

 

I will gladly share my code later tonight and we can discuss in detail, if you want to. 

 

Cheers

Vd

  • Thanks 1

Share this post


Link to post
Share on other sites
16 hours ago, Vandeanson said:

Hiho, 

 

Exactly the type of feature that i have spend my recent nights tinkering with! 

 

Use the cursorObject command and get the model  (.p3d) from the object.

_model = (getModelInfo cursorObject) select 0;

do not work with classnames when comparing your (map) object against an array. 

 

You can use the same command to look at map objects and return their model name, if you do not want to dig into the config. 

I learned recently that most map objects will not return a classname. (thanks yuki:)) 

 

I am working on a similar gathering system (e.G. Picking apples from apple trees, pumpkins from pumpkin plants,.. ) and will extend my system with scripts to gather berries, roots, mushrooms,... 

from map objects. 

 

I have opted out to use addactions/holdactions or a looped check to assign these gathering actions to objects. 

My current solution is a hotkey based system that executes different gathering scripts based on your cursorobject (look at an apple tree , press hotkey and gather apples). I think this is a good approach as it doesnt require loops to constantly run in the background. Code is only executed upon request. 

 

Also, you should consider to add a fallback option in case you do not have space in your inventory, so instead the loot will be dropped on the ground nearby. (else its lost if you do not have space). 

 

I will gladly share my code later tonight and we can discuss in detail, if you want to. 

 

Cheers

Vd

 

I added you on Discord 🙂

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

×