ReferenceFilesystem

openfiledialog

Asks the user to select one file.

Syntax

openfiledialog(options: table?) -> DialogItem?

Parameters

ParameterTypeDescription
optionstable?Dialog title, initial location and extension preferences.

Returns

TypeDescription
DialogItem?Selected item, or nil on cancellation.

Description

The options table accepts title, defaultPath, suggestedName, defaultExtension and extensionFilter. The extension filter is a list of extensions, for example {"txt", "json"}. The dialog yields while waiting for the user. Canceling returns nil and does not grant access to a path.

Returned items expose methods for the selected file or folder. They are not arbitrary filesystem paths. External changes to the selected object can invalidate an item.

Example

local item = openfiledialog({ title = "Choose file" })
if item then print(item:GetName()) end

These are Game executor contracts. Check build requirements and session lifetimes before using them.