Skip to content

Commit

Permalink
Add API to blacklist variables from transfer (#13)
Browse files Browse the repository at this point in the history
* Add gvar and gvar usage

- Mods can add to the array on postinit to blacklist their variables

* Update addons/main/functions/fnc_actionSwap.sqf

Co-authored-by: Jouni Järvinen <[email protected]>

---------

Co-authored-by: Jouni Järvinen <[email protected]>
  • Loading branch information
some-evil-kitty and rautamiekka authored May 22, 2024
1 parent 8e04adf commit 22d4203
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion addons/main/functions/fnc_actionOnChest.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ private _backpackVariables = [];
{
private _val = (backpackContainer _unit) getVariable _x;
_backpackVariables pushBack [_x, _val];
} forEach (allVariables (backpackContainer _unit));
} forEach ((allVariables (backpackContainer _unit) - GVAR(VarBlacklist)));

[_unit, _backpack, _backpackLoadout, _backpackVariables, _backpackLoad] call FUNC(addChestpack);

Expand Down
2 changes: 1 addition & 1 deletion addons/main/functions/fnc_actionSwap.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ if ((_backpack isEqualTo "") or ([_unit] call FUNC(chestpack)) isEqualTo "") exi
{
private _val = (backpackContainer _unit) getVariable _x;
_backpackVariables pushback [_x, _val];
} forEach (allVariables (backpackContainer _unit));
} forEach ((allVariables (backpackContainer _unit) - GVAR(VarBlacklist)));

//remove packs
[_unit] call FUNC(removeChestpack);
Expand Down
5 changes: 5 additions & 0 deletions addons/main/initSettings.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,8 @@
true, // default value
true // isGlobal
] call CBA_fnc_addSetting;

// Blacklisted variables for mods that don't want variables to be transferred. Useful for very particular cases.
GVAR(VarBlacklist) = [

];

0 comments on commit 22d4203

Please sign in to comment.