This error takes some effort to reproduce, but the behavior is very strange, and it only acts this way in 2.7, so I think it’s a bug in 2.7 lua.
How to reproduce:
-
Install the code into 2.7.
-
Bind Global:View:Toggle Plugin Windows to some key
-
Open energy xt 2.5.4 external editor(I found about half of vsti’s gives this error, energy xt is one example)
-
Press toggle key, external editor disappears, “start of function” is displayed in terminal showing that the function is called
-
Press the toggle key again, external editor reappears, “start of function” printed again.
-
Press the toggle key a third time, nothing happens, the function doesn’t even get called - no “start of function” message.
-
Press the key a fourth time, now the function gets called again.
-
Repeat above in 2.6, everything works as it should.
Maybe the error is connected to this.
Here’s the code:
[luabox]
–[[
Toggles plugin windows on or off
–]]
renoise.tool():add_keybinding {
name = “Global:View:Toggle Plugin Windows”,
invoke = function(repeated) toggle_plugins() end
}
local openInstruments = {}
function toggle_plugins()
print(“start of function”)
– save all instruments where external editor is opened
local tempOpenInstruments = {}
for i,v in ipairs(renoise.song().instruments) do
if (v.plugin_properties.plugin_loaded) then
if (v.plugin_properties.plugin_device.external_editor_visible) then
table.insert(tempOpenInstruments,i)
end
end
end
if ( #tempOpenInstruments>0 ) then
– there are open plugin windows
– save and close instruments
openInstruments={}
for i,v in ipairs(tempOpenInstruments) do
table.insert(openInstruments,v)
end
for i,v in ipairs(openInstruments) do
renoise.song().instruments[v].plugin_properties.plugin_device.external_editor_visible=false
end
else
– there are no open plugin windows, restore saved
– restore instruments
if (#openInstruments>=1) then
for i,v in ipairs(openInstruments) do
renoise.song().instruments[v].plugin_properties.plugin_device.external_editor_visible=true
end
end
openInstruments = {}
end
end
[/luabox]