RNavega wrote: ↑Mon Oct 12, 2020 9:51 pm
Does the audio system exist at the point where the 'newSource' function gets called? Regarding the timeline of events, is the sound loading at least invoked from within love.load() or later?
I would be concerned with using LÖVE's systems/API at any point before love.load() is called. Later than that should be fine (after all systems were initialized).
The newSource is in a file named sound.lua. It names a few sources and has two play functions, just simple audio.play(). The only mention of sound.lua before love.load() is the require for the file. As far as I've read, you can do anything above love.load() and it will read it as if it's in or below love.load().
The error traces back to my require function, which consists of
------
local conf_files = {}
recursiveEnumerate('conf', conf_files)
requireFiles(conf_files)
local object_files = {}
recursiveEnumerate('objects', object_files)
requireFiles(object_files)
local room_files = {}
recursiveEnumerate('rooms', room_files)
requireFiles(room_files)
----- from there it sends the files to...
function recursiveEnumerate(folder, file_list)
local items = love.filesystem.getDirectoryItems(folder)
for _, item in ipairs(items) do
local file = folder .. '/' .. item
if love.filesystem.getInfo(file, 'file') then
table.insert(file_list, file)
elseif love.filesystem.getInfo(file, 'directory') then
--recursiveEnumerate(file, file_list)
end
end
end
function requireFiles(files)
for _, file in ipairs(files) do
local file = file:sub(1, -5)
require(file)
end
end
I commented out the rE() for the directory because it was causing issues, I probably have something wrong but wasn't ready to dive into that issue yet. When I commented out the rE() the program ran fine. As long as I wasn't trying to run the exe.
For the person asking about sound.lua contents, I just saw your comment. Here it is.
missilefx = love.audio.newSource("sound/missile.ogg", "static")
pew = love.audio.newSource("sound/pew.ogg", "static")
splat = love.audio.newSource("sound/splat.ogg", "static")
franks = love.audio.newSource("sound/franks.ogg", "stream")
coinappear = love.audio.newSource("sound/coin.ogg", "static")
coincollect = love.audio.newSource("sound/coincollect.ogg", "static")
thunder = love.audio.newSource('sound/thunder.ogg', 'static')
pain = love.audio.newSource('sound/pain.ogg', 'stream')
pain:setLooping(true)
franks:setLooping(true)
love.audio.setVolume(.01)
function music(x)
local sound = x
if sound:isPlaying() == false then
playSound(sound)
end
end
function playSound(sound)
sound:play()
end