anaximandross 34 Posted March 1, 2019 Hello all, So I'm writing a script that will be used as a function to create groups of units. The issue I'm having is that every single group that I create, needs to have a dynamic variable name, since if I use _group = createGroup in a script it will just keep creating the same group ID. I was going to try to use Format to name the groups, but I haven't used it before, and I got a little lost in the syntax. This is what I have so far: Spoiler //creates a group of the given size (_this select 3) params ["_side","_groupSize","_spawnPosition"]; //determine side of units if ("_side" isEqualTo "EAST") then { //create the group and name it private _group = createGroup ["EAST",1]; private _group = format[_group,_spawnPosition]; for [{private _i =0}, {_i = _spawnPosition}, {_i + 1}] do { //create random units and add them to the group //these units should also each have a unique name (i think) private _unit = group player createUnit ["B_RangeMaster_F", position player, [], 0, "FORM"]; }; }else{ //same code, but for West }; Thanks in advance! Share this post Link to post Share on other sites
7erra 629 Posted March 1, 2019 44 minutes ago, anaximandross said: format[_group,_spawnPosition]; The format command only accepts strings as the first param. What you can do though is use setVariable. private _group = createGroup ["EAST",true]; // why is there a 1 in your script? _id = time; //(or sth similar to identify it) _groupVarName = format ["EastGroup:%1",_id]; missionNamespace setVariable [_groupVarName,_group]; // access it later again: _groupVarName = format ["EastGroup:%1",_id]; _group = missionNamespace getVariable [_groupVarName,grpNull]; if (!isNull _group) then {/*group exists*/}; Depending on what you intend to do in the script later there might be better ways. This is just a quick answere and not tested. 1 Share this post Link to post Share on other sites
anaximandross 34 Posted March 1, 2019 Ok, i will try this out and see how it works! And the createGroup command can use either true, false, 0, or 1 for the final argument to it. IIRC, in Boolean ogic, true =1, false = 0, so they're interchangeable. Share this post Link to post Share on other sites
Grumpy Old Man 3546 Posted March 1, 2019 5 hours ago, anaximandross said: Ok, i will try this out and see how it works! And the createGroup command can use either true, false, 0, or 1 for the final argument to it. IIRC, in Boolean ogic, true =1, false = 0, so they're interchangeable. Unless you actually tried that out I'd be surprised, since bool and scalar are different data types, at least in .sqf. Cheers Share this post Link to post Share on other sites
anaximandross 34 Posted March 1, 2019 8 hours ago, Grumpy Old Man said: Unless you actually tried that out I'd be surprised, since bool and scalar are different data types, at least in .sqf. Cheers I guess I got my commands backwards! I thought I saw it in their example code on the BIKI, but I was wrong. Good catch! 1 Share this post Link to post Share on other sites
7erra 629 Posted March 1, 2019 There are some commands which accept both though: [1,2] select 0; //1 [1,2] select false; //1 Share this post Link to post Share on other sites