gc8 970 Posted January 9, 2021 Hi Is it possible to dynamically change the title of action created by BIS_fnc_holdActionAdd? I tried setUserActionText but that did nothing. I also checked the code of BIS_fnc_holdActionAdd but it seems that the title you pass in remains the same in the script. Any ideas? thx! Share this post Link to post Share on other sites
M1ke_SK 230 Posted January 9, 2021 remove / re-add with updated text 2 Share this post Link to post Share on other sites
Schatten 267 Posted January 9, 2021 @gc8, BIS_fnc_holdActionAdd returns action ID. I'm sure you can use it to change the title using setUserActionText command. Share this post Link to post Share on other sites
gc8 970 Posted January 9, 2021 1 hour ago, Schatten said: @gc8, BIS_fnc_holdActionAdd returns action ID. I'm sure you can use it to change the title using setUserActionText command. That's what I thought too but BIS_fnc_holdActionAdd also uses setUserActionText, so it's overriding anything set by setUserActionText Share this post Link to post Share on other sites
ZaellixA 383 Posted January 10, 2021 I believe that M1ke_SK's solution is the easiest (from a conceptual point of view at least) one. You could create a custom function to add a holdAction to a unit and another one to remove it and just pass the title (to the one that adds the action) and the ID (to the one that removes the action) to take advantage of code reuse. In this way, the whole process could boil down to something like // Assume your functions are called // GC8_fnc_addAction and GC8_fnc_removeAction // GC8_fnc_addAction should return the action ID // // I will use player as the unit to add the action to // I am sure you know your way around to change that ;) // Add the initial action private _id = [player, "Initial Title"] call GC8_fnc_addAction; // Check for condition that changes the title waitUntil { sleep 5; // Change that according to your needs /* The condition check */; }; // Change the title [_id] call GC8_fnc_removeAction; _id = [player, "New Title"] call GC8_fnc_addAction; You could also make it more generic by giving the option to the user to pass all arguments needed to add a holdAction and use some default values if not given by the user but I believe that this could be overkill if you intend to use it with a specific holdAction (with fixed conditions and code to be run on execution, etc.). I know I haven't been of much help here, but I do hope you'll manage to find a solution to your problem. Share this post Link to post Share on other sites
gc8 970 Posted January 10, 2021 (edited) @ZaellixA thanks for the help. I think the easiest way to do this is simply have two actions created with different title texts. So I would as example create "Assemble gun" and "Disassemble gun" actions and then put in the actions show condition the right code to show just one of those at a time Edit: The reason I feel like this is because I think having loops running is too much hassle Edited January 10, 2021 by gc8 Share this post Link to post Share on other sites
ZaellixA 383 Posted January 10, 2021 Well, this could make the work too, yes. Running loops is indeed a bit of a hassle, but you have to keep in mind that (show) conditions will be checked on a regular basis, albeit in the background without you having to explicitly code them. Nevertheless, you may end up being more efficient in the long run (on average) the conditions of the holdAction are not be checked when a player is not looking at the object and/or is further than 50 metres away. This is the case for the "simple" action, see this for more info. It is stated that: Quote "If action is added to an object (and not to player) condition will only get evaluated IF player is closer than ~50m to the object surface AND is looking at the object". I am not sure whether this is the case with the holdAction too, so I cannot even get an estimate of whether you will achieve better performance. Share this post Link to post Share on other sites
Larrow 2800 Posted January 11, 2021 Messy Test Piece Spoiler [ player, "Place Quad", "\a3\ui_f\data\igui\cfg\holdactions\holdaction_search_ca.paa", "\a3\ui_f\data\igui\cfg\holdactions\holdaction_search_ca.paa", "true", "true", //Start {}, //Progress { params ["_target", "_caller", "_actionId", "_arguments", "_frame"]; if ( isNil "placedQuad" ) then { _title = format["<t color='#FFFFFF' align='left'>Placing Quadbike in </t><t color='#83ffffff' align='right'>%1</t>",24-_frame]; }else{ _title = format["<t color='#FFFFFF' align='left'>Removing Quadbike in </t><t color='#83ffffff' align='right'>%1</t>",24-_frame]; }; [_target,_actionID,"",_iconProgress,bis_fnc_holdAction_texturesProgress, _frame, _title] call bis_fnc_holdAction_showIcon; }, //Complete { params ["_target", "_caller", "_actionId", "_arguments", "_frame"]; _state = if ( isNil "placedQuad" ) then { placedQuad = createVehicle[ "B_quadbike_01_f", _caller getPos[ 5, getDir _caller ], [], 0, "CAN_COLLIDE" ]; "Remove Quad" }else{ deleteVehicle placedQuad; placedQuad = nil; "Place Quad" }; _keyNameRaw = actionKeysNames ["Action",1,"Keyboard"]; _keyName = _keyNameRaw select [1,count _keyNameRaw - 2]; _keyNameColored = format["<t color='#ffae00'>%1</t>",_keyName]; _hint = format[localize "STR_A3_HoldKeyTo",_keyNameColored,_state]; _title = format["<t font='RobotoCondensedBold'>%1</t>",_hint]; _h = [ _target, _actionID, _title, _iconIdle, _hint ] spawn { params[ "_target", "_actionID", "_title", "_iconIdle", "_hint" ]; waitUntil{ !bis_fnc_holdAction_running && { scriptDone bis_fnc_holdAction_scriptHandle } }; _target setUserActionText [_actionID,_title,bis_fnc_holdAction_texturesProgress select 0,_iconIdle + "<br/><br/>" + _hint]; } }, //Iterrupt { }, [], 10, 1, false, false, true ] call BIS_fnc_holdActionAdd; _h = [] spawn { //Let BI's part of holdAction _condShow run once waitUntil{ !isNil "bis_fnc_holdAction_animationIdleFrame" && { bis_fnc_holdAction_animationIdleFrame > 0 } }; //Stop action _condShow from updating actionText with original title missionNamespace setVariable ["bis_fnc_holdAction_animationIdleTime",1e10]; }; What the consequences are of remove BI's idle update user text seems to disappear on occasion but something for you to play with. 1 Share this post Link to post Share on other sites
link 22 0 Posted January 11, 2021 Thanks for sharing this information. link22 Share this post Link to post Share on other sites
gc8 970 Posted January 11, 2021 @ZaellixA It's not performance that I worry about this but rather the simplicity. it's better to have the engine run the action codes than using scripted loops. that's also faster 2 hours ago, Larrow said: What the consequences are of remove BI's idle update you know I was thinking that you could copy the entire BIS_fnc_holdActionAdd code and make a modified version of that which allows the title changing 1 Share this post Link to post Share on other sites