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:
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.
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.
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.
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.