66 posts
Location
Minecraft world
Posted 15 April 2017 - 11:01 AM
Hello so i was just wondering if it is possible for me to like when i do fs.list i want it too only display folders and not programs. I want too do this because i'm trying to make a program to display all programs but folders in a different color
Thanks¨
SOLVED!
Edited on 15 April 2017 - 11:54 AM
100 posts
Location
Sublime Text 2
Posted 15 April 2017 - 11:05 AM
there is a function in an api, i thought it was fs that gives you a boolean when the file is a directory… i think it is fs.isDirectory(path)
66 posts
Location
Minecraft world
Posted 15 April 2017 - 11:07 AM
Ye i found something like that too its fs.isReadOnly but how could i use that in fs.list?
2427 posts
Location
UK
Posted 15 April 2017 - 11:24 AM
--# use fs.list to get all of the files and folders in the current directory
filesAndFolders = fs.list()
--# for each file and folder check it is a folder
for i = 1, #filesAndFolders do
if fs.isDirectory(filesAndFolders[i]) then
table.insert(folders, filesAndFolders[i])
end
end
Edited on 15 April 2017 - 09:25 AM
66 posts
Location
Minecraft world
Posted 15 April 2017 - 11:25 AM
Thank you Lupus i'ma try it now
66 posts
Location
Minecraft world
Posted 15 April 2017 - 11:38 AM
--# use fs.list to get all of the files and folders in the current directory
filesAndFolders = fs.list()
--# for each file and folder check it is a folder
for i = 1, #filesAndFolders do
if fs.isDirectory(filesAndFolders[i]) then
table.insert(folders, filesAndFolders[i])
end
end
It gave me an error on line 11
2427 posts
Location
UK
Posted 15 April 2017 - 12:15 PM
there isn't a line 11 in my code, so you will need to point out which line is 11 or provide your full code
edit: it might be that folders is nil when i pass it to table.insert, try making an empty table called folders before the for loop
Edited on 15 April 2017 - 10:17 AM
66 posts
Location
Minecraft world
Posted 15 April 2017 - 12:22 PM
Ok i will try
Ok i will try
It didn't give an error but now its blank
I think i can figure that out
Thanks!
66 posts
Location
Minecraft world
Posted 15 April 2017 - 12:45 PM
there isn't a line 11 in my code, so you will need to point out which line is 11 or provide your full code
edit: it might be that folders is nil when i pass it to table.insert, try making an empty table called folders before the for loop
Thanks you for the support now it works!!