system.listFiles¶
since 1.5.0
List files in a directory.
Parameters¶
| Name | Type | Required | Description |
|---|---|---|---|
directory |
string | yes |
Returns¶
files (table of strings)
Examples¶
-- list .wav files in our sounds folder
for _, name in ipairs(system.listFiles("SCRIPTS:/myscript/sounds") or {}) do
if name:match("%.wav$") then print(name) end
end
Scanning storage is slow. Do it once (on open, or when the pilot asks) and keep the result, never from wakeup.
Real-world usage¶
Called 18 times across 6 open-source Ethos Lua projects. A few short excerpts: