fitGroup
Definition
-- @/lua/ge/extensions/core/multiSpawn.lua:660
local function fitGroup(group, amount) -- fits a group to the given table size
local groupSize = #group
if groupSize == 0 then return group end
amount = amount or groupSize
local nextIndex = 0
if groupSize < amount then
for i = groupSize, amount - 1 do
nextIndex = nextIndex + 1
if (nextIndex % (groupSize + 1)) == 0 then
nextIndex = 1
end
table.insert(group, deepcopy(group[nextIndex]))
end
elseif groupSize > amount then
for i = groupSize, amount + 1, -1 do
table.remove(group, i)
end
end
return group
end
Callers
@/lua/ge/extensions/core/multiSpawn.lua
local groupCopy = deepcopy(group)
groupCopy = fitGroup(groupCopy, amount)
@/lua/ge/extensions/gameplay/traffic.lua
if fileData then
fileData = core_multiSpawn.fitGroup(fileData, policeAmount)
log('I', logTag, string.format('Loaded police group from file: %s', fileName or ''))
if fileData then
fileData = core_multiSpawn.fitGroup(fileData, amount)
log('I', logTag, string.format('Loaded traffic group from file: %s', fileName or ''))