Function; SobGroup_FillShipsByIndexRange - HWRM/KarosGraveyard GitHub Wiki
SobGroup_FillShipsByIndexRange(<target_group>, <source_group>, <begin_at>, <selection_count>)
Adds selection_count
amount of ships from source_group
to target_group
, beginning at the index begin_at
.
It is not possible to know ahead of time the ordering of a SobGroup, so begin_at
is mostly used for things like selecting a ship at a random index. There is a chance that ships defined in a .level
can be accessed by a predictable index.
SobGroup_Split
may be a somewhat friendlier function to use.
local supports_group = SobGroup_Fresh();
Player_FillShipsByType(supports_group, 0, "kus_supportfrigate");
local individual_frigates = {};
local end_index = SobGroup_Count(supports_group) - 1;
for i = 0, end_index do
local subgroup = SobGroup_Fresh();
SobGroup_FillShipsByIndexRange(subgroup, supports_group, i, 1);
individual_frigates[i + 1] = subgroup;
end
-- now we can interact with support frigates as individuals:
for _, frigate in individual_frigates do
-- ...
end
See:
Sobgroup_Fresh
.
Param | Type | Description |
---|---|---|
target_group |
string |
The name of the SobGroup to add ships into. |
source_group |
number |
The name of the original, unsplit source group. |
begin_at |
number |
Integer indicating the index to begin adding ships from. |
selection_count |
number |
The amount of ships to add from source_group . |