Getting Files From The Save Directory

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
uederson
Prole
Posts: 30
Joined: Mon May 23, 2016 7:59 pm
Location: Brazil
Contact:

Getting Files From The Save Directory

Post by uederson »

Hi friends!
In my game I will let the users create their own levels.
At moment I know how to save the created levels (they are created inside the save directory).
The problem is that I will need to list the created levels to let the user choose one of them, but when I use the function love.filesystem.getDirectoryItems() it shows only the files that are inside the main folder (where is the main.lua). From the save directory the function returns a empty string.
Can someone pls point me how can I get the files from the save directory? Or if it is not possible, is there some way I could save the levels inside some other folder?

I save the created levels using this code:

Code: Select all

love.filesystem.write(name_of_level..".lua",serialize(level_table))
[Edit]I found a better way to do it (I think it is better): I will insert the name of the created levels inside a table.
But I would like to know why I can not get the list of files from the Save Directory using love.filesystem.getDirectoryItems()

Thank you in advance!
Uederson
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: Getting Files From The Save Directory

Post by raidho36 »

This function should return files from both the package and the save directory. My guess is that you didn't​ set game identity properly, so it couldn't access the files it wrote.

I suggest that you create a dedicated directory for user levels, that way there is no ambiguity between package files and save files.
uederson
Prole
Posts: 30
Joined: Mon May 23, 2016 7:59 pm
Location: Brazil
Contact:

Re: Getting Files From The Save Directory

Post by uederson »

raidho36 wrote: Thu May 25, 2017 10:01 pm I suggest that you create a dedicated directory for user levels, that way there is no ambiguity between package files and save files.
Thank you, friend!
I will do it!
Post Reply

Who is online

Users browsing this forum: No registered users and 161 guests