Jump to content




fs.list Filters?

api computer utility

8 replies to this topic

#1 danielsv03

  • Members
  • 66 posts
  • LocationMinecraft world

Posted 15 April 2017 - 10: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 by danielsv03, 15 April 2017 - 12:54 PM.


#2 ReBraLaCC

  • Members
  • 100 posts
  • LocationSublime Text 2

Posted 15 April 2017 - 10: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)

#3 danielsv03

  • Members
  • 66 posts
  • LocationMinecraft world

Posted 15 April 2017 - 10:07 AM

Ye i found something like that too its fs.isReadOnly but how could i use that in fs.list?

#4 Lupus590

  • Members
  • 2,029 posts
  • LocationUK

Posted 15 April 2017 - 10: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 by Lupus590, 15 April 2017 - 10:25 AM.


#5 danielsv03

  • Members
  • 66 posts
  • LocationMinecraft world

Posted 15 April 2017 - 10:25 AM

Thank you Lupus i'ma try it now

#6 danielsv03

  • Members
  • 66 posts
  • LocationMinecraft world

Posted 15 April 2017 - 10:38 AM

View PostLupus590, on 15 April 2017 - 10:24 AM, said:

--# 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

#7 Lupus590

  • Members
  • 2,029 posts
  • LocationUK

Posted 15 April 2017 - 11:15 AM

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 by Lupus590, 15 April 2017 - 11:17 AM.


#8 danielsv03

  • Members
  • 66 posts
  • LocationMinecraft world

Posted 15 April 2017 - 11:22 AM

Ok i will try

View Postdanielsv03, on 15 April 2017 - 11:19 AM, said:

Ok i will try
It didn't give an error but now its blank

I think i can figure that out

Thanks!

#9 danielsv03

  • Members
  • 66 posts
  • LocationMinecraft world

Posted 15 April 2017 - 11:45 AM

View PostLupus590, on 15 April 2017 - 11:15 AM, said:

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!!





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users