Ace3: interact_menu sets `this` global variable.

Created on 8 Mar 2020  路  8Comments  路  Source: acemod/ACE3

Description:
interact_menu sets this global variable:

https://github.com/acemod/ACE3/blob/b778df2c3bb48b058046c0107fdc902eaa09d56a/addons/interact_menu/functions/fnc_keyUp.sqf#L28
https://github.com/acemod/ACE3/blob/b778df2c3bb48b058046c0107fdc902eaa09d56a/addons/interact_menu/functions/fnc_render.sqf#L94

Expected behavior:
A global variable should NOT be set called this, it should be named in some manner so as to not easily conflict with other uses. If you are trying to hack the use of this in a subsequent call you should find a better way, this is not reliable in any case.

kinbug

All 8 comments

Agreed.

The problem is taking something like
statement = "([this, 1, 1] call BIS_fnc_Door)";
and converting any use of this to a neutral gvar isn't easy in sqf

Can't you just unset the magic variable after the statement if you want to keep bwc?
And also backup the previous value before setting it?

Is this code guaranteed to run atomically (I might hope ui event handlers do but I have no idea)? If so then yeah definitely store previous this value and restore it afterwards.

Is this code guaranteed to run atomically

Pretty much all of ACE is, because the scheduler is cancer.

and converting any use of this to a neutral gvar isn't easy in sqf

stringReplace command useful here?

No, that is more complicated than a temporary variable holding this.

Parsing something like this would be awful:
Statement = "hint 'this is the way!'; [this] call fnc_empathise";

probably just save and restore the var
same issue here: https://github.com/acemod/ACE3/blob/master/addons/repair/functions/fnc_normalizeHitPoints.sqf#L50

// Define global variables
Total = damage _vehicle;
Was this page helpful?
0 / 5 - 0 ratings

Related issues

thirald picture thirald  路  3Comments

armyinf0703 picture armyinf0703  路  3Comments

JudahHarvey picture JudahHarvey  路  4Comments

Herbiie picture Herbiie  路  3Comments

DieselJC picture DieselJC  路  3Comments