Donut Team is a labor of love, built and maintained by a small group of passionate developers. We invest our own time and resources to offer our tools, mods, and web services completely free of charge.

We don't run ads, and we will never sell your data - period.

If you've enjoyed anything we've created, please consider supporting our work with a one-time or monthly donation via our Ko-fi page . Every contribution helps us continue building great experiences for the community.

Dismiss
  • Modding Tools
  • Simpsons Hit & Run Multiplayer Server
  • Lua API Reference
  • Directory Functions

Directory.Scan

Available since Version 1.0.

Scans a directory and returns a table containing the names of all files and subdirectories within it.

Syntax

Directory.Scan( path, [pattern] )

Arguments

  • path (string): The path of the directory to scan. This can be an absolute path or a path relative to the mod's directory.
  • pattern (string, optional): A pattern to match file names against. Defaults to "*" if not specified.

Return Values

  • (table): A table containing the names of all files and subdirectories within the specified directory. The keys of the table are integers starting from 1, and the values are strings representing the names of the files and subdirectories.

Examples

local scannedFiles = Directory.Scan("events", "*.lua")

for i = 1, #scannedFiles do
    File.RequireOnce(scannedFiles[i])
end