Fix SoundGroup:get method

This commit is contained in:
Jordan Irwin 2021-08-09 14:07:20 -07:00
parent 245f77f0ea
commit c797635445

28
api.lua
View File

@ -224,20 +224,30 @@ SoundGroup = {
local count = self:count() local count = self:count()
if count == 0 then return end if count == 0 then return end
local retval
if type(idx) == "number" then if type(idx) == "number" then
return self[idx] retval = self[idx]
elseif count == 1 then
retval = self[1]
else
retval = {}
for _, snd in ipairs(self) do
table.insert(retval, snd)
end
end end
if count == 1 then if self.no_prepend ~= true then
return self[1] local rtype = type(retval)
if rtype == "string" then
retval = "sounds_" .. retval
elseif rtype == "table" then
for idx, snd in ipairs(retval) do
retval[idx] = "sounds_" .. snd
end
end
end end
local all_sounds = {} return retval
for _, snd in ipairs(self) do
table.insert(all_sounds, snd)
end
return all_sounds
end, end,
} }
setmetatable(SoundGroup, SoundGroup.__init) setmetatable(SoundGroup, SoundGroup.__init)