Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handle returned assignments in key events #1214

Merged
merged 1 commit into from
Aug 23, 2019

Conversation

commy2
Copy link
Contributor

@commy2 commy2 commented Aug 23, 2019

When merged this pull request will:

  • Atm. keybindings that return assignments error:

Test script (15 is tab key):

["Test001", "Action001", "Test Text", {
    systemChat str diag_frameNo;
    0 = 0
}, {}, [15, [false, false, false]], false] call CBA_fnc_addKeybind;

Before: generic error in expression
After: works, assignment treated as "false" (like any other non boolean return value).

@commy2 commy2 added the Bug Fix label Aug 23, 2019
@commy2 commy2 added this to the 3.13 milestone Aug 23, 2019
@commy2 commy2 merged commit 75e6bfb into master Aug 23, 2019
@commy2 commy2 deleted the keybinding-assignment-safe-return branch August 23, 2019 20:44
@@ -72,7 +72,7 @@ private _blockInput = false;
_params pushBack + _keybindParams;
_params pushBack _x;

_blockInput = ([_params call _code] param [0, false] isEqualTo true) || {_blockInput};
_blockInput = ([nil] apply {_params call _code} param [0, false] isEqualTo true) || {_blockInput};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0 would be faster than nil but would ofc define _x, doubt that would break anyones code?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_x previously leaked into the user's code block alongside all the other locals like _params, _code and _keybindParams etc.
One could also use [_x] I suppose to keep the _x the same.
I just don't care about micro optimizations like that. The code is still a fifth of what it used to be before my rewrite and no one ever complained about it.
_x being nil was just the logical thing, as in "this variable I never defined is undefined", from the users perspective.

@commy2 commy2 modified the milestones: 3.13, 3.12.2 Sep 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants