Directory path

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
randomNick
Prole
Posts: 6
Joined: Fri Aug 07, 2015 10:38 pm

Directory path

Post by randomNick »

So i tried this code to list the files in a certain directory

Code: Select all

local dir = ""

local files = love.filesystem.getDirectoryItems(dir)

function love.draw()
	for i,v in ipairs(files) do
		love.graphics.print(v, 0, i*10)
	end
end
this one works, but if i change the dir to something like: "C:/Users/Username/Documents" it doesnt list anything. and i also tried giving the complete directory to the main folder and it doesnt work too.
randomNick
Prole
Posts: 6
Joined: Fri Aug 07, 2015 10:38 pm

Re: Directory path

Post by randomNick »

So i realized that love can only access the save directory and the .love's root directory.

so i change the code to

Code: Select all

love.filesystem.setIdentity("testFolder")

local files = love.filesystem.getDirectoryItems("")

function love.draw()
	for i,v in ipairs(files) do
		love.graphics.print(v, 0, i*10)
	end
end
and it read files from testFolder and the folder where i have the main.lua. that's ok, but when i made the .exe file it stopped working (worked fine .love)

what else do i have to change
davisdude
Party member
Posts: 1154
Joined: Sun Apr 28, 2013 3:29 am
Location: North Carolina

Re: Directory path

Post by davisdude »

Files are read from a different directory when in .exe's vs .love's. That might be the issue.
GitHub | MLib - Math and shape intersections library | Walt - Animation library | Brady - Camera library with parallax scrolling | Vim-love-docs - Help files and syntax coloring for Vim
randomNick
Prole
Posts: 6
Joined: Fri Aug 07, 2015 10:38 pm

Re: Directory path

Post by randomNick »

indeed

.love is saving to AppData/Roaming/LOVE while
.exe is saving to AppData/Roaming
User avatar
T-Bone
Inner party member
Posts: 1492
Joined: Thu Jun 09, 2011 9:03 am

Re: Directory path

Post by T-Bone »

To be more precise, the paths are AppData/Roaming/LOVE/yourgameID/ and AppData/Roaming/yourgameID/ respectively.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot] and 5 guests