-
Notifications
You must be signed in to change notification settings - Fork 16
gmlDialogs Library
Will Thomas edited this page Apr 2, 2014
·
2 revisions
A collection of common dialogs packed up ready-to-use from a single function call.
##gmlDialogs.filePicker
###Usage
gmlDialogs.filePicker(mode,path,name,extension)
- mode
- required. Mode can be either "save" or "load" and tells whether you're wanting a save file dialog or a load file dialog; each has different conditions for it's file, e.x., "save" mode will not accept a file in a read-only directory, and open will not accept a file which does not exist.
- path
- optional. The directory to initially display in the file picker dialog. Default is the root directory.
- name
- optional. A suggested name to initially populate the file name text field.
- extension
- optional. If specified, an extension to require for the file. Will not open files without this extension, and will append it filenames without an extension when returning.
- Returns: string or nil
- Returns either the name of the file to save/load, or nil if the user hit "cancel."
###Example:
This example code would show the save dialog, then save the contents of the data variable to the specified filename, if the user did not cancel.
local saveAs=gmlDialogs.filePicker("save")
if saveAs then
local file=io:open(saveAs,"w")
file:write(data)
file:close()
print("data saved to "..saveAs)
else
print("save canceled")
end