Advanced-Equipment icon indicating copy to clipboard operation
Advanced-Equipment copied to clipboard

`ace_interact_menu_consolidateSingleChild` Setting prevents insertion of USB Drives

Open mrschick opened this issue 4 months ago • 6 comments

When the "ACE Interaction Menu" setting called "Consolidate single child actions" (ace_interact_menu_consolidateSingleChild) is enabled, the following error occurs when trying to plug in a USB Drive. 20240219142407_1 As a result, the USB Drive can not be plugged in unless the setting is disabled. The ACE Interaction interface also somewhat bugs itself and remains in view despite releasing ⊞ Win, requiring going back to a previous node to unstick it, though that is probably just the way Ace reacts to an interaction's exception.

mrschick avatar Feb 19 '24 13:02 mrschick

Maybe #406 could fix this, I'll check it out if I find the time.

mrschick avatar Feb 19 '24 14:02 mrschick

Interesting. I will have a look into it.

y0014984 avatar Feb 19 '24 14:02 y0014984

Issue is also present in #406. It occurs at addons\flashdrive\functions\fnc_initInterface.sqf:57

private _condition = 
{
	params ["_target", "_player", "_params"];
	(_params select 0) params ["_index", "_name", "_rel_pos", "_rot_yaw", "_rot_pitch", "_rot_roll"];
	private _occupiedList = _target getVariable "AE3_USB_Interfaces_occupied";

	isNull (_occupiedList select _index);
};

Apparently when consolidateSingleChild is enabled, _index is filled with the USB Drive's full Config name, i.e: Item_FlashDisk_AE3_ID_1, instead of the index corresponding to the selected (unoccupied) interface.

mrschick avatar Feb 25 '24 21:02 mrschick

Got it.

Basically, when consolidateSingleChild is disabled, the condition is called with the _params parameter just containing data on the respective interface, like so:

[[1,"USB1",[-0.19,-0.028,-0.145],90,0,180]]

However, when consolidateSingleChild is enabled, the Drive's classname is prepended to the parameter, resulting in the following format:

["Item_FlashDisk_AE3_ID_1",[1,"USB1",[-0.19,-0.028,-0.145],90,0,180]]

I guess that's just an ACE quirk, will investigate further.

Because of this, (_params select 0) params in the condition's code will then parse _index = "Item_FlashDisk_AE3_ID_1", leading to the error in _occupiedList select _index.

params ["_target", "_player", "_params"];
(_params select 0) params ["_index", "_name", "_rel_pos", "_rot_yaw", "_rot_pitch", "_rot_roll"];
private _occupiedList = _target getVariable "AE3_USB_Interfaces_occupied";

isNull (_occupiedList select _index);

I found a fix, basically checking if the first element of _params is an Array and parsing either index 0 or 1 as interface data depending on that (detailed here in #406). It should always work, as when carrying more than 1 USB Drive, the action would not be consolidated.

mrschick avatar Apr 12 '24 19:04 mrschick

I guess that's just an ACE quirk, will investigate further.

Indeed, child params are used with parent condition code. Please check if it's fixed with acemod/ACE3#9946.

Dystopian avatar Apr 13 '24 00:04 Dystopian

Can confirm that your PR fixes this issue, many thanks 👍🏻

mrschick avatar Apr 13 '24 21:04 mrschick