eagledude4 3 Posted May 15, 2014 I'd like for someone to explain to me why: getItemArray = { _return = []; if (typeName _this == "STRING") then { for "_c" from 0 to ((count INV_AllMissionObjects) - 1) do { if (((INV_AllMissionObjects select _c) select 0) == _this) then { _return = INV_AllMissionObjects select _c; }; }; } else { diag_log format ["ERROR: Input type for %1 was %2 and needs to be STRING", _this, typeName _this]; }; _return; }; works, and: getItemArray = { if (typeName _this == "STRING") then { for "_c" from 0 to ((count INV_AllMissionObjects) - 1) do { if (((INV_AllMissionObjects select _c) select 0) == _this) exitwith { INV_AllMissionObjects select _c; }; }; } else { diag_log format ["ERROR: Input type for %1 was %2 and needs to be STRING", _this, typeName _this]; }; }; doesn't. Share this post Link to post Share on other sites
mariodu62 5 Posted May 15, 2014 using call or spawn for this function ? Share this post Link to post Share on other sites
mariodu62 5 Posted May 15, 2014 but you don't store the result anywhere. Can you write the main script ? Share this post Link to post Share on other sites
Larrow 2822 Posted May 15, 2014 Remove the semicolon ; after the line you want returned .. eg myFunc = { _randomItems = ["a","b","c","d","e","f","g"]; if (typeName _this == typeName "") then { for "_c" from 0 to ((count _randomItems)-1) do { if ((_randomItems select _c) == _this) exitWith { _randomItems select _c }; }; }else{ hint "didnt work muppet"; }; }; "c" call myFunc Share this post Link to post Share on other sites
eagledude4 3 Posted May 15, 2014 (edited) Wouldnt the ; after "_return" in my first example be wrong then too? Edited May 16, 2014 by eagledude4 Share this post Link to post Share on other sites
Larrow 2822 Posted May 16, 2014 Wouldnt the ; after "_return" in my first example be wrong then too? Following the syntax rules you would generally think so yes. See Return Value on this page https://community.bistudio.com/wiki/Function. Presume as its expecting a returned value that the last expression is used. Share this post Link to post Share on other sites
eagledude4 3 Posted May 18, 2014 Thanks, Larrow. Bookmarked that page Share this post Link to post Share on other sites
Tankbuster 1746 Posted May 18, 2014 Yes, don't put a semicolon after the return variable. Share this post Link to post Share on other sites