fn_Quiksilver 1633 Posted November 27, 2016 After an interesting question on the arma 3 discord, about how to add actions to trees, here is what we came up with. Paste this block somewhere that the client machine will execute it (init.sqf, initplayerlocal.sqf, etc) comment "Paste this block somewhere that the clients machine will execute it."; if (isDedicated) exitWith {}; if (!hasInterface) exitWith {}; tag_fnc_myTreeCode = { comment 'This is your tree function!'; _cursorObject = cursorObject; if (!(['\tree\',((getModelInfo _cursorObject) select 1),FALSE] call BIS_fnc_inString)) exitWith {titleText ['Sorry Im nota tree!','PLAIN',1];}; titleText ['Hello human','PLAIN',1]; }; tag_fnc_isTargetTree = { private _return = FALSE; _cursorObject = cursorObject; if (!isNull _cursorObject) then { if ((player distance _cursorObject) < 10) then { _modelInfo = getModelInfo _cursorObject; if (!(_modelInfo isEqualTo [])) then { if (['\tree\',(_modelInfo select 1),FALSE] call BIS_fnc_inString) then { _return = TRUE; }; }; }; }; _return; }; tag_var_action = [ 'Hello tree', tag_fnc_myTreeCode, nil, 50, TRUE, TRUE, '', '[] call tag_fnc_isTargetTree', 5, FALSE ]; player addAction tag_var_action; player addEventHandler [ 'Respawn', { player addAction tag_var_action; } ]; The client will be able to walk up and scroll on a tree. Edit the code above for your uses. 6 Share this post Link to post Share on other sites
Grumpy Old Man 3540 Posted November 27, 2016 Alternatively you could also use nearestTerrainObjects to retrieve the trees. Cheers 4 Share this post Link to post Share on other sites
R0adki11 3945 Posted November 27, 2016 I Hope you add an option to hug trees ;) 5 Share this post Link to post Share on other sites
Tajin 348 Posted November 28, 2016 Alternatively you could also use nearestTerrainObjects to retrieve the trees. Not really a good alternative though. Besides, you still wouldn't be able to add actions directly to them. cursorObject is the right way to go! ps.: In general this is a great way to add interaction with a large amount of objects, without having to use addAction on every single one of them. Share this post Link to post Share on other sites
Bnae 1431 Posted November 28, 2016 Clever idea, done this a little differently to make objects lootable. Wink wink for survival scripters. 1 Share this post Link to post Share on other sites
fn_Quiksilver 1633 Posted November 28, 2016 Clever idea, done this a little differently to make objects lootable. Wink wink for survival scripters. Yep The guy who asked how to go about adding action to trees, wanted it for some sort of farming/logging in Life mod. Only catch is simple objects don't have namespace, so you won't be able to attach variable directly to the object, you would have to create your own scripted namespace to hold the object and any associated data. Share this post Link to post Share on other sites