Jump to content
Sign in to follow this  
rlex

Double array units

Recommended Posts

Some weird question here, wanted to improve my DUWS fork...

I have array of units like that

_group = [_position, EAST, ["O_Soldier_TL_F","O_Soldier_AR_F","O_Soldier_LAT_F","O_Soldier_GL_F"],[],[],opfor_ai_skill] call BIS_fnc_spawnGroup;

This is called from main script

_handle = [_trigger, _size] execvm "createoppatrol.sqf";

So i introduce variable, for example

_multiplier = X

Where X is, for example, 2.

And i need array of

["O_Soldier_TL_F","O_Soldier_AR_F","O_Soldier_LAT_F","O_Soldier_GL_F"]

To be multiplied by 2, so the end result will look like

["O_Soldier_TL_F","O_Soldier_AR_F","O_Soldier_LAT_F","O_Soldier_GL_F","O_Soldier_TL_F","O_Soldier_AR_F","O_Soldier_LAT_F","O_Soldier_GL_F"]

Is that possible? I have two potential options in my head (but i do not know how to do that and not sure that this is even possible in SQF):

1) Array multiplication, what i described...

2) Run script X times, something like

while {a =< _multiplier} do {
a = a + 1;
_handle = [_trigger, _size] execvm "createoppatrol.sqf";
};

Thanks in advance.

Share this post


Link to post
Share on other sites
_someArray = ["O_Soldier_TL_F","O_Soldier_AR_F","O_Soldier_LAT_F","O_Soldier_GL_F"];
_multipliedArray = [];
_multiplier = 2;
if (_multiplier < 0) then {_multiplier = 1};

for "_i" from 0 to (_multiplier - 1) step 1 do
{
_multipliedArray = _multipliedArray + _someArray;
};

Edited by JShock

Share this post


Link to post
Share on other sites
_someArray = ["O_Soldier_TL_F","O_Soldier_AR_F","O_Soldier_LAT_F","O_Soldier_GL_F"];
_multipliedArray = [];
_multiplier = 2;
if (_multiplier < 0) then {_multiplier = 1};

for "_i" from 0 to (_multiplier - 1) step 1 do
{
_multipliedArray = _multipliedArray + _someArray;
};

Thank you very much!

Can i use reference of _multipliedArray in another array, ie

_group = [_position, EAST, _multipliedArray],[],[],opfor_ai_skill] call BIS_fnc_spawnGroup;

?

Share this post


Link to post
Share on other sites

Yep, and you have an extra "]" in there, fixed below :):

_group = [_position, EAST, _multipliedArray,[],[],opfor_ai_skill] call BIS_fnc_spawnGroup;

Share this post


Link to post
Share on other sites
Yep, and you have an extra "]" in there, fixed below :):

_group = [_position, EAST, _multipliedArray,[],[],opfor_ai_skill] call BIS_fnc_spawnGroup;

Thank you again. Coded that into DUWS and it's working now. Wasn't great idea after i saw amount of units... But still fun.

Share this post


Link to post
Share on other sites
Did you make DUWS? If so, I had a great time playing it

No, i maintain my own fork since original was abandoned.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×