trouble with the dynamic_building_matrix example tool

Heya, was wondering if someone could help me…im trying to merge the example “dynamic_building_matrix” from the “example_gui” tool from the xrnx starter kit into the “create tool” tool …i havnt changed anything apart from the strings in variable “note_strings” and the amount of rows & columns…there is something i am obviously missing an understanding of as when i cntrl + save + reload tool all im getting is an >>

[details=“Click to view contents”] *** No matching overload found, candidates:
*** custom [class Dialog] show_custom_dialog(Application const&,custom [class String] const&,View*,luabind::object const&,lua_State*)
*** custom [class Dialog] show_custom_dialog(Application const&,custom [class String] const&,View*,lua_State*)
*** stack traceback:
*** [C]: in function ‘show_custom_dialog’
*** main.lua:86: in main chunk [/details]

if anyone has the time to look over this and tell me where im going wrong id be very grateful… [details=“Click to view contents”]
–[[============================================================================
main.lua
============================================================================]]–

– Placeholder for the dialog
local dialog = nil

– Placeholder to expose the ViewBuilder outside the show_dialog() function
local vb = nil

– Reload the script whenever this file is saved.
– Additionally, execute the attached function.
_AUTO_RELOAD_DEBUG = function()

end

– Read from the manifest.xml file.
class “RenoiseScriptingTool” (renoise.Document.DocumentNode)
function RenoiseScriptingTool:__init()
renoise.Document.DocumentNode.__init(self)
self:add_property(“Name”, “Untitled Tool”)
self:add_property(“Id”, “Unknown Id”)
end

local manifest = RenoiseScriptingTool()
local ok,err = manifest:load_from(“manifest.xml”)
local tool_name = manifest:property(“Name”).value
local tool_id = manifest:property(“Id”).value


– Main functions

– This example function is called from the GUI below.
– It will return a random string. The GUI function displays
– that string in a dialog.


– GUI

function dynamic_building_matrix()

local vb = renoise.ViewBuilder()

local CONTENT_MARGIN = renoise.ViewBuilder.DEFAULT_CONTROL_MARGIN
local BUTTON_WIDTH = 2*renoise.ViewBuilder.DEFAULT_CONTROL_HEIGHT

local NUM_OCTAVES = 4
local NUM_NOTES = 1

local note_strings = {
“1/32”, “1/16”, “1/8”, “1/4”
}

– create the main content column, but don’t add any views yet:
local dialog_content = vb:column {
margin = CONTENT_MARGIN
}

for octave = 1,NUM_OCTAVES do
– create a row for each octave
local octave_row = vb:row {}

for note = 1,NUM_NOTES do
local note_button = vb:button {
width = BUTTON_WIDTH,
text = note_strings[note]…tostring(octave - 1),

notifier = function()
– functions do memorize all values in the scope they are
– nested in (upvalues), so we can simply access the note and
– octave from the loop here:
show_status((“note_button %s%d got pressed”):format(
note_strings[note], octave - 1))
end

}
– add the button by “hand” into the octave_row
octave_row:add_child(note_button)
end

dialog_content:add_child(octave_row)
end

renoise.app():show_custom_dialog(dialog_content)

end


– Menu entries

–[[
renoise.tool():add_menu_entry {
name = “Main Menu:Tools:”…tool_name…"…",
invoke = show_dialog
}
–]]


– Key Binding

–[[
renoise.tool():add_keybinding {
name = “Global:Tools:” … tool_name…"…",
invoke = show_dialog
}
–]]


– MIDI Mapping

–[[
renoise.tool():add_midi_mapping {
name = tool_id…":Show Dialog…",
invoke = show_dialog
}
–]] [/details]

When calling show_custom_dialog() you are required to provide a title for the dialog window along with the ViewBuilder content.

This will work:

renoise.app():show_custom_dialog("My Lovely Dialog", dialog_content)  

aha, thanks again sir, will try this now :slight_smile:

Sweet,so here is the updated function>>>

[details=“Click to view contents”] function runtest()

local vb = renoise.ViewBuilder()

local CONTENT_MARGIN = renoise.ViewBuilder.DEFAULT_CONTROL_MARGIN
local BUTTON_WIDTH = 2*renoise.ViewBuilder.DEFAULT_CONTROL_HEIGHT

local NUM_DIVISIONS = 4
local NUM_COLUMNS = 1

local division_strings = {
“1/32”, “1/16”, “1/8”, “1/4”
}

– create the main content column, but don’t add any views yet:
local dialog_content = vb:column {
margin = CONTENT_MARGIN
}
for division = 1,NUM_DIVISIONS do
– create a row for each octave
local division_row = vb:row {}

for column = 1,NUM_COLUMNS do
local division_text_box = vb:text {
text = division_strings,

}
– add the button by “hand” into the division_row
division_row:add_child(division_text_box)
end

dialog_content:add_child(division_row)
end

renoise.app():show_custom_dialog(“My Lovely Dialog”, dialog_content)

end [/details]

this works, but when “division_strings” is called by vb:text the terminal is claiming it needs a string, which is im guessing is because Lua auto converts strings to numbers(and vice versa), and as division_strings is a table with only math operations in each table position its not liking it. I tried using “text = tostring(division_strings)”, this compiles and runs but gives me 4 textfields (all placed correctly mind you) with strings that equate “table ((insert some mad hex number here))”… ive tried escaping the table contents to make it read as strings but having no luck…any idea anyone?

The text property expects a single string value, but your variable division_strings is obviously a table (an array) containing multiple string values. You can not directly assign a table full of strings to a singular text property in this way.

I don’t know your full intentions for this script, or how the divisions and columns will come into play later, but perhaps you can try something like this instead:

local division_text_box = vb:text {  
 text = division_strings[division],  
}  

Interestingly enough, you already had this working in your earlier version of the script (which I tested) :]

aha, of course, it needs to know the position of the table to call…
the idea is just to have another two columns, one with milliseconds length, and one with the frequency length both corresponding to the bpm set in renoise…both in numberbox format so it will be easy to copy and paste into any parameter within renoise…just a handy calculator really…

Its getting there…:slight_smile:

Click to view contents
  
--[[============================================================================  
main.lua  
============================================================================]]--  
  
-- Placeholder for the dialog  
local dialog = nil  
  
-- Placeholder to expose the ViewBuilder outside the show_dialog() function  
local vb = nil  
  
-- Reload the script whenever this file is saved.   
-- Additionally, execute the attached function.  
_AUTO_RELOAD_DEBUG = function()  
  
end  
  
-- Read from the manifest.xml file.  
class "RenoiseScriptingTool" (renoise.Document.DocumentNode)  
 function RenoiseScriptingTool:__init()   
 renoise.Document.DocumentNode.__init(self)   
 self:add_property("Name", "Untitled Tool")  
 self:add_property("Id", "Unknown Id")  
 end  
  
local manifest = RenoiseScriptingTool()  
local ok,err = manifest:load_from("manifest.xml")  
local tool_name = manifest:property("Name").value  
local tool_id = manifest:property("Id").value  
  
  
  
--------------------------------------------------------------------------------  
-- Main functions  
--------------------------------------------------------------------------------  
  
  
  
  
--------------------------------------------------------------------------------  
-- GUI  
--------------------------------------------------------------------------------  
 function runtest()  
 local songbpm = renoise.song().transport.bpm  
 local vb = renoise.ViewBuilder()  
  
 local CONTENT_MARGIN = renoise.ViewBuilder.DEFAULT_CONTROL_MARGIN  
 local BUTTON_WIDTH = 2*renoise.ViewBuilder.DEFAULT_CONTROL_HEIGHT  
  
 local NUM_DIVISIONS = 6  
 local NUM_COLUMNS = 1  
 local division_strings = {  
 "1/32", "1/16", "1/8", "1/4", "1/2", "1/1"  
 }  
  
 -- create the main content column, but don't add any views yet:  
 local dialog_content = vb:column {}  
 dialog_content.style = "group"  
 dialog_content.margin = CONTENT_MARGIN  
  
 for division = 1,NUM_DIVISIONS do  
 -- create a row for each division  
 local division_row = vb:row {}  
  
 for column = 1,NUM_COLUMNS do  
 local division_text_box = vb:text  
 {  
 text = division_strings[division],  
 }  
  
 local divised = 0  
 for divising = 1, NUM_DIVISIONS do  
 if (division == 1) then divised = (60000 / songbpm) * (1/8)  
 elseif (division == 2) then divised = (60000 / songbpm) * (1/4)   
 elseif (division == 3) then divised = (60000 / songbpm) * (1/2)   
 elseif (division == 4) then divised = (60000 / songbpm) * (1/1)   
 elseif (division == 5) then divised = (60000 / songbpm) * (1/0.5)   
 elseif (division == 6) then divised = (60000 / songbpm) * (1/0.25)  
 else divised = 0  
 end  
 end   
  
 local division_ms_box = vb:valuebox  
 {  
 max = 9999,  
 value = divised  
 }  
  
 -- add the button by "hand" into the division_row  
  
 division_row:add_child(division_text_box)  
 division_row:add_child(division_ms_box)  
 end  
  
 dialog_content:add_child(division_row)  
 end  
  
 renoise.app():show_custom_dialog("MS Calculator", dialog_content)  
  
 end  
  
  
  
--------------------------------------------------------------------------------  
-- Menu entries  
--------------------------------------------------------------------------------  
  
renoise.tool():add_menu_entry {  
 name = "Main Menu:Tools:"..tool_name.."...",  
 invoke = runtest   
}  
  
  
  
--------------------------------------------------------------------------------  
-- Key Binding  
--------------------------------------------------------------------------------  
  
--[[  
renoise.tool():add_keybinding {  
 name = "Global:Tools:" .. tool_name.."...",  
 invoke = show_dialog  
}  
--]]  
  
  
--------------------------------------------------------------------------------  
-- MIDI Mapping  
--------------------------------------------------------------------------------  
  
--[[  
renoise.tool():add_midi_mapping {  
 name = tool_id..":Show Dialog...",  
 invoke = show_dialog  
}  
--]]