## Skip File in Enumeration?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
TurtleP
Party member
Posts: 147
Joined: Thu Mar 22, 2012 9:20 pm
Contact:

### Skip File in Enumeration?

Hello all,

In my game, there are mappacks that come with the game, and I don't want users to be able to select a certain mappack from the selection menu. I tried the following:

Code: Select all

if not love.filesystem.isFile("maps/Board the Platforms") then
mappackstable = love.filesystem.enumerate("maps/")
end
But to no avail, it still is reading it for selection.

Santos
Party member
Posts: 384
Joined: Sat Oct 22, 2011 7:37 am

### Re: Skip File in Enumeration?

You could store the map in a different folder, or you could remove the string from the table by looping through it backwards, checking to see if it's the string to remove, and if it is, using table.remove.

Code: Select all

maps = love.filesystem.enumerate("maps/")

for i = #maps, 1, -1 do
if maps[i] == "Board the Platforms" then
table.remove(maps, i)
end
end
There isn't really a reason for looping through it backwards in this instance, but if there were multiple things to remove it's useful so it doesn't miss anything, because table.remove moves the rest of the table down, and if the loop continues moving forward it might skip over something.

TurtleP
Party member
Posts: 147
Joined: Thu Mar 22, 2012 9:20 pm
Contact:

### Re: Skip File in Enumeration?

Santos wrote:You could store the map in a different folder, or you could remove the string from the table by looping through it backwards, checking to see if it's the string to remove, and if it is, using table.remove.

Code: Select all

maps = love.filesystem.enumerate("maps/")

for i = #maps, 1, -1 do
if maps[i] == "Board the Platforms" then
table.remove(maps, i)
end
end
There isn't really a reason for looping through it backwards in this instance, but if there were multiple things to remove it's useful so it doesn't miss anything, because table.remove moves the rest of the table down, and if the loop continues moving forward it might skip over something.
Thanks! I had something similar when i touched something like a key in the game, but never thought of this.

### Who is online

Users browsing this forum: tiss and 54 guests