Rommel 1 Posted October 27, 2009 VARX = format ["%1", {alive _x; _x} foreach allunits]; Returns the last unit in allUnits; VARX = format ["%1", {alive _x} foreach allunits]; Returns true; Semi strange behavior, considering: VARX= {alive _x} foreach allunits Returns nothing. Share this post Link to post Share on other sites
madrussian 276 Posted October 27, 2009 That is weird indeed. Share this post Link to post Share on other sites
Gigan 1 Posted October 27, 2009 The third description also returns true or false (VARX) in my test. All three description returns the value at the tail end variable in {}. The reason which returns a result seems to be consistently satisfactory. Share this post Link to post Share on other sites
Rommel 1 Posted October 27, 2009 (edited) Interesting, where did you execute the code? I did mine in triggers, and it would not return anything. I'll give it a shot executing in init.sqf. edit: Yup, works in init.sqf Edited October 27, 2009 by Rommel Share this post Link to post Share on other sites
bhaz 0 Posted October 27, 2009 VARX = format ["%1", {alive _x; _x} foreach allunits]; Returns the last unit in allUnits; {alive _x; _x} - that last ;_x is returned, and since _x refers to the item passed into the block, this one makes sense. Why those last two come back different, that's confusing, thought it would've worked anywhere. :confused: Share this post Link to post Share on other sites
Rommel 1 Posted October 27, 2009 Which is what intrigued me, the first two make sense. Share this post Link to post Share on other sites
Gigan 1 Posted October 27, 2009 (edited) sleep 1;VARX= {alive _x} foreach allunits; //The third description. player sidechat format["%1",VARX]; I think that no results are returned because the assignment expression itself is written to the format command. In order to display a script error, it is good to carry out -showScriptErrors option use. @bhaz "format ["%1", {alive _x; _x} foreach allunits]" is decomposed. format["%1",{alive _x(0); _x(0); alive _x(1); _x(1); alive _x(2); _x(2)}] "format ["%1", {alive _x} foreach allunits]" is decomposed. format["%1",{alive _x(0); alive _x(1); alive _x(2)}] "{alive _x} foreach allunits" is decomposed. {alive _x(0); alive _x(1); alive _x(2)} The result of red returns, respectively. Edited October 27, 2009 by Gigan Share this post Link to post Share on other sites
Rommel 1 Posted October 27, 2009 I think that no results are returned because the assignment expression itself is written to the format command.In order to display a script error, it is good to carry out -showScriptErrors option use. I had that on, it just would return nothing. As in, nothing... doesn't matter. I was just seeing if I could retrieve an array instead of the last variable in a for each loop without concatenation or pushing arrays. Share this post Link to post Share on other sites
Gigan 1 Posted October 27, 2009 How is the result of having tried this? in init.sqf sleep 1;VARX= {alive _x} foreach allunits; //The third description. player sidechat format["%1",VARX]; By my test, as for this result, true returns to a value. Share this post Link to post Share on other sites