Lineman 3 Posted August 27, 2018 Trying to spawn a group of units with each unit having a variable name so I can do stuff like give each a unique loadout after spawning. Everything seems to work, until the last line of the below script "removeUniform SpawnSoldier_02;". I receive an error "error removeuniform: type string, expected object". Spoiler SpawnSoldier_02 = "B_SOLDIER_A_F"; SpawnSoldier_03 = "fow_s_ger_heer_rifleman"; _unitsInGroup = [SpawnSoldier_02, SpawnSoldier_03]; newGroup = createGroup [west,true]; _SpawnSoldier_01 = "fow_s_ger_heer_rifleman" createUnit [_CorpSpawnPosition,newGroup,"SpawnSoldier_01 = this"]; sleep 1; { _x createUnit [_CorpSpawnPosition,newGroup,"_x = this"]; sleep .4; }forEach _unitsInGroup; sleep 1; removeUniform SpawnSoldier_02; Share this post Link to post Share on other sites
Mr H. 402 Posted August 27, 2018 As you have defined it spawnsoldier_02 is the string of the class name, not the created unit 1 Share this post Link to post Share on other sites
Lineman 3 Posted August 27, 2018 Just now, Mr H. said: As you have defined it spawnsoldier_02 is the string of the class name, not the created unit Thanks that helps! It was meant to be the variable of the created unit. Share this post Link to post Share on other sites
Mr H. 402 Posted August 27, 2018 Also the "_x =this" in your initial parameter won't work, it will be treated as part of the string and not as a variable 1 Share this post Link to post Share on other sites
Lineman 3 Posted August 27, 2018 Spoiler _SpawnSoldier_02 = "B_SOLDIER_A_F" createUnit [_CorpSpawnPosition,newGroup,"SpawnSoldier_02 = this"]; sleep .4; _SpawnSoldier_03 = "fow_s_ger_heer_rifleman" createUnit [_CorpSpawnPosition,newGroup,"SpawnSoldier_03 = this"]; sleep .4; _SpawnSoldier_04 = "fow_s_ger_heer_rifleman" createUnit [_CorpSpawnPosition,newGroup,"SpawnSoldier_04 = this"]; sleep.4; removeUniform SpawnSoldier_02; Decided to define the variables separately rather than using an array and it works. Thanks again! Share this post Link to post Share on other sites
Schatten 284 Posted August 27, 2018 @Lineman, { call (compile (format (["%1 = '%2' createUnit [_CorpSpawnPosition, newGroup];"] + _x))); } forEach [ ["SpawnSoldier_02", "B_SOLDIER_A_F"], ["SpawnSoldier_03", "fow_s_ger_heer_rifleman"] ]; sleep 1; removeUniform SpawnSoldier_02; 2 Share this post Link to post Share on other sites
Dedmen 2693 Posted September 4, 2018 On 27.8.2018 at 9:44 PM, Schatten said: call (compile (format (["%1 = '%2' createUnit [_CorpSpawnPosition, newGroup];"] + _x))); call compile format combination is almost always stupid. missionNamespace setVariable [_x select 0, (_x select 1) createUnit [_CorpSpawnPosition, newGroup]]; 1 Share this post Link to post Share on other sites
Schatten 284 Posted September 4, 2018 15 minutes ago, Dedmen said: call compile format combination is almost always stupid. Really? Proofs? Share this post Link to post Share on other sites
Dedmen 2693 Posted September 4, 2018 3 hours ago, Schatten said: Really? Proofs? Put this into debug console and benchmark it missionNamespace setVariable ["abc", 123]; vs call compile format ["%1 = %2", "abc", 123]; 2 Share this post Link to post Share on other sites
Grumpy Old Man 3545 Posted September 4, 2018 Just for the curious: missionNamespace setVariable ["abc", 123];//0.001ms call compile format ["%1 = %2", "abc", 123];//0.0025ms Performance loss is kinda given. Some other reason for not using call compile format, in terms of sending code via network, though a bit unrelated to this topic. Cheers Share this post Link to post Share on other sites
HazJ 1289 Posted September 4, 2018 5 hours ago, Dedmen said: call compile format combination is almost always stupid. missionNamespace setVariable [_x select 0, (_x select 1) createUnit [_CorpSpawnPosition, newGroup]]; Didn't know! :O Quote It is magical Share this post Link to post Share on other sites
Grumpy Old Man 3545 Posted September 4, 2018 @HazJ how are you running the setVariable one for 0.0007ms? Do I really need to upgrade my CPU already? Heh... Cheers Share this post Link to post Share on other sites
HazJ 1289 Posted September 4, 2018 Not sure lol. i7 8700k 1080 Ti 32 GB DDR4 etc Share this post Link to post Share on other sites
Harzach 2517 Posted September 4, 2018 (edited) Woo! Got you beat by a whole five ten-thousandths of a second on the call compile format, Haz! Yeehaw! Edited September 4, 2018 by Harzach fixed for Ded 1 Share this post Link to post Share on other sites
Dedmen 2693 Posted September 4, 2018 People need to learn how to make non-fullscreen screenshots that don't show 80% useless empty space :D Also no need to argue about the perf. call compile format is just stupid. PERIOD *slams fists on table*. Thanks for watching. Now to the news with Karen Bablewitz. 3 Share this post Link to post Share on other sites