Page 1 of 1

[Problem] Love.filesystem.enumerate() doesnt work!

Posted: Tue Mar 20, 2012 5:10 pm
by rickydaan
Hey, I just started on a filesystem program, and i alreaddy have a problem;

I get this error:

Traceback:
[C]: In function Enumerate
main.lua:8 in function 'draw'
[C]: in function 'XPcall'

Main.lua is my online file, and config.lua (Wich is basic)

Code: Select all

function love.load()
end

function love.draw()
dirWorking = love.filesystem.getWorkingDirectory()
love.graphics.print(dirWorking, 100,100)

files = love.filesystem.enumerate()
print(files)
end

function love.update(dt)
end

function love.focus(bool)
end

function love.keypressed( key, unicode )
end

function love.keyreleased( key, unicode )
	
end

function love.mousepressed( x, y, button )
end

function love.mousereleased( x, y, button )
end

function love.quit()
end

Re: [Problem] Love.filesystem.enumerate() doesnt work!

Posted: Tue Mar 20, 2012 5:32 pm
by trubblegum
https://love2d.org/wiki/love.filesystem.enumerateI don't see anywhere that an argument is optional.

Re: [Problem] Love.filesystem.enumerate() doesnt work!

Posted: Tue Mar 20, 2012 6:15 pm
by Robin
Try this:

Code: Select all

function love.load()
	files = love.filesystem.enumerate('')
end

function love.draw()
	dirWorking = love.filesystem.getWorkingDirectory()
	love.graphics.print(dirWorking, 10,10)

	for i, file in ipairs(files) do
		love.graphics.print(file, 10, 30 * i)
	end
end
Do you see the difference?

Re: [Problem] Love.filesystem.enumerate() doesnt work!

Posted: Wed Mar 21, 2012 7:01 am
by rickydaan
Ooh, It needed strings >.<

Thanks for the help!

And how to use the read() function, as it says:
Calling global read() at line xxx

Re: [Problem] Love.filesystem.enumerate() doesnt work!

Posted: Wed Mar 21, 2012 9:35 am
by Robin

Code: Select all

   for i, file in ipairs(files) do
      -- do something with:
      love.filesystem.read(file)
   end