48 lines
1.5 KiB
Lua
48 lines
1.5 KiB
Lua
|
local fs=love.filesystem
|
||
|
group=object:extend()
|
||
|
function group:addDirectory(directory) files=fs.getDirectoryItems(directory)
|
||
|
for i,currentfile in ipairs(files) do
|
||
|
fullpath=directory .."/" ..currentfile
|
||
|
if not fs.isDirectory(fullpath) and not (currentfile:sub(1,1)==".") then
|
||
|
if fs.getInfo(fullpath, file) then
|
||
|
nameOnly=string.match(currentfile, "%P+") --%P matches all non punctuation characters
|
||
|
sound=love.audio.newSource(fullpath, "static")
|
||
|
if sound:typeOf("Source") then
|
||
|
--print("Loaded " .. nameOnly)
|
||
|
if sound:getChannelCount()==1 then sound:setRelative(true) end
|
||
|
self[nameOnly]=sound
|
||
|
self.sounds[nameOnly] =sound
|
||
|
end --if is a sound
|
||
|
end --if it's a file
|
||
|
end -- if it's not a dot
|
||
|
|
||
|
end --for
|
||
|
end --addDirectory
|
||
|
function group:new(directory)
|
||
|
|
||
|
self.sounds={}
|
||
|
self:addDirectory(directory)
|
||
|
|
||
|
end
|
||
|
|
||
|
function group:setEffect(effect)
|
||
|
--print("setting effects on group")
|
||
|
for i,currentsource in pairs(self) do
|
||
|
|
||
|
if currentsource.typeOf~=nil and currentsource:typeOf("Source") then
|
||
|
if currentsource:setEffect(effect) then
|
||
|
--print("effect set on " ..i)
|
||
|
else
|
||
|
print("failed to set effect on " ..i)
|
||
|
end
|
||
|
end --if it's a source
|
||
|
end --for loop
|
||
|
end --setEffect function
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
t={
|
||
|
a=2,
|
||
|
b=3
|
||
|
}
|