46 posts
Posted 06 March 2016 - 04:49 PM
Hey.
Simple issue here, I don't work with tables since I'm a novice and have almost no idea what I am doing.
All I am trying to do is print tables that are obtained via fs.list() and print them into a nice list.
How would I do this?
Thanks!
129 posts
Location
I honestly don't know
Posted 06 March 2016 - 05:06 PM
for file in fs.list() do
print(file)
end
Edited on 06 March 2016 - 04:06 PM
46 posts
Posted 06 March 2016 - 05:11 PM
for file in fs.list() do
print(file)
end
This didn't work. It still is expecting a string, which it isn't getting.
129 posts
Location
I honestly don't know
Posted 06 March 2016 - 05:16 PM
ok, i get whats happening. fs.list() requires and argument of the directory you want it to list.
in simple terms, you have to tell it what to list.
for example, if you want to get all the files in the root directory, '/', you would use:
fs.list('/')
7083 posts
Location
Tasmania (AU)
Posted 06 March 2016 - 10:24 PM
That, and the "for" loop itself expects a function, such as the one returned by ipairs.
for _, file in ipairs( fs.list( "/" ) ) do
print( file )
end
There's also
textutils.serialise() and
textutils.tabulate().
Edited on 06 March 2016 - 09:44 PM
2679 posts
Location
You will never find me, muhahahahahaha
Posted 06 March 2016 - 10:42 PM
This should not work either. The generic for loop requires a function, which would be returned by fs.list. But this one returns a table. The way to do it is:
for i,file in pairs(fs.list(path)) do
print(file)
end
Ninja'd. And that is what I get for not refreshing the page.
Edited on 06 March 2016 - 09:42 PM