Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help,
read this.
-
TurtleP
- Party member
- Posts: 147
- Joined: Thu Mar 22, 2012 9:20 pm
-
Contact:
Post
by TurtleP » Sun Dec 30, 2012 3:01 am
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
Post
by Santos » Sun Dec 30, 2012 7:51 am
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:
Post
by TurtleP » Sun Dec 30, 2012 10:43 pm
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.
Users browsing this forum: tiss and 54 guests