Page MenuHomeFeedback Tracker

Alternative syntax of createUnit accepting local variables in init
Feedback, NormalPublic

Description

Prior to version 2.18, the init section in the alternative syntax of createUnit was accepting local variables from the higher scope. Changes to the variables in the init were accessible to the higher scope. When version 2.18 came out, this stopped working.

There are circumstances where the first syntax is problematic - spawning units into a group of a side other than their init leads to friendly fire, even if a joinSilent is used.

There are also circumstances where using the alternate syntax with global variables is a problem - running mulitple instances of a spawn script at the same time would either cause the wrong units to spawn in the wrong places, or require many global variables to be managed.

If this was a fix for what was seen as a bug, is possible to implement an efficient way to pass local variables into and out of the init? Would it be possible to alter the first syntax to automatically join the side of the group, or create a third syntax that solves all these issues?

Details

Severity
None
Resolution
Open
Reproducibility
Always
Operating System
Windows 10 x64
Category
General
Steps To Reproduce

Enable legacy 2.16 version and run the code to see previous functionality. _position is passed into the init of the unit creation and sets the correct height. _soldier is changed from "" to the unit itself in the init, and is available to the higher scope for further use:

_position = getPosATL player;
_thisGroup = createGroup [east, true];
_element = "B_Soldier_F";
_soldier = "";
_element createUnit [_position, _thisGroup, "this setPosATL _position; this disableAI 'ALL'; _soldier = this;"];
hint format ["%1", _soldier];

Additional Information

Event Timeline

Revision: 152294

BIS_fnc_KK changed the task status from New to Feedback.Oct 18 2024, 10:34 PM