Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Function checking if given string/array with strings is in _keys array
- // If so then it returns true
- // and sets _pressed variable to that string/last array item
- private ["_item", "_return", "_last", "_i", "_j", "_max"];
- _return = false;
- if (_this in [_this]) then
- {
- // for single string
- if (_this in _keys && !(_this in _pressed)) then
- {
- // click
- _pressed = _pressed + [_this];
- _return = true;
- };
- // release
- if (!(_this in _keys) && _this in _pressed) then
- {
- _pressed = _pressed - [_this];
- };
- }
- else
- {
- _item =+ _this;
- // Sub-Arrays - alternative keys
- _i = 0;
- while "_i < count _item" do
- {
- // If a sub-array
- if (!((_item select _i) in [(_item select _i)])) then
- {
- // Remove from _pressed
- "if (!(_x in _keys)) then {_pressed=_pressed-[_x]}" forEach (_item select _i);
- // If one of the key is pressed
- _j = 0;
- _max = count (_item select _i);
- while "_j < _max" do
- {
- if (((_item select _i) select _j) in _keys) then {_item set [_i, (_item select _i) select _j]; _j=_max};
- _j = _j + 1;
- };
- // If none were pressed
- if (_j==_max) then {_item set [_i, "false"]};
- };
- _i = _i + 1;
- };
- // for an array
- _last = _item select (count _item -1);
- if ("_x in _keys" count _item == count _item && !(_last in _pressed)) then
- {
- // click
- _pressed = _pressed + [_last];
- _return = true;
- };
- // release
- if (!(_last in _keys) && _last in _pressed) then
- {
- _pressed = _pressed - [_last];
- };
- };
- _return
Add Comment
Please, Sign In to add comment