mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-06 23:05:04 +01:00
Add an example plugin to demonstrate Lua global variables
Note: this only works when loading the script action. Window > Scripting doesn't run the factory method for upindex variables
This commit is contained in:
parent
86a78dc100
commit
e612be9037
1 changed files with 37 additions and 0 deletions
37
scripts/_remember_file.lua
Normal file
37
scripts/_remember_file.lua
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
ardour {
|
||||
["type"] = "EditorAction",
|
||||
name = "File Name Test",
|
||||
author = "Ardour Lua Taskforce",
|
||||
description = [[Example Plugin to show to to select a file and remember the most recently used file.]]
|
||||
}
|
||||
|
||||
function factory ()
|
||||
local file_name_testscript_last_filename -- this acts as "global" variable, use a unique name
|
||||
return function ()
|
||||
print (file_name_testscript_last_filename) -- debug
|
||||
|
||||
--set filename to most recently used, fall back to use a default
|
||||
local fn = file_name_testscript_last_filename or ARDOUR.LuaAPI.build_filename (Session:path (), Session:name () .. ".ardour")
|
||||
|
||||
-- prepare a dialog
|
||||
local dialog_options = {
|
||||
{ type = "file", key = "file", title = "Select a File", path = fn }
|
||||
}
|
||||
|
||||
-- show dialog
|
||||
local od = LuaDialog.Dialog ("title", dialog_options)
|
||||
local rv = od:run()
|
||||
|
||||
if rv then
|
||||
-- remember most recently selected file
|
||||
file_name_testscript_last_filename = rv['file']
|
||||
LuaDialog.Message ("title", "set path to " .. file_name_testscript_last_filename, LuaDialog.MessageType.Info, LuaDialog.ButtonType.Close):run()
|
||||
else
|
||||
-- unset most recently used filename on dialog "cancel"
|
||||
file_name_testscript_last_filename = nil
|
||||
end
|
||||
|
||||
od = nil
|
||||
collectgarbage ()
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue