question about showing custom values in a jbox.value_display widget

This forum is for developers of Rack Extensions to discuss the RE SDK, share code, and offer tips to other developers.
wendallsan
Posts: 45
Joined: 10 Dec 2017

Post 18 Jun 2021

I'm trying t set up a jbox.value_display to show note values ("C4, A1, F#2, etc") based on a jbox.number custom property. I have a test case that I think should show 2 available note options (C0 and C#0), but I'm getting an error in Recon when I try to create an instance of my rack extension. If I replace my units property in motherboard_ref.lua with a simple "units = {{decimals=0}}" I get the expected behavior of a display that will show 0 or 1 and the value can be changed with the up/down buttons, so I'm pretty sure the problem is in my units declaration in the motherboard_ref.lua file. Can anyone tell me what I have wrong with my units declaration? Many thanks for any help!

Here is the error I get in recon:

Code: Select all

Error when creating device: Error compiling <redacted>/motherboard_def.lua. Error message: Error at line 21: '}' expected (to close '{' at line 19) near '=' (LUA_ERRSYNTAX ---)
I have in my hdgui_2D.lua file:

Code: Select all

back = jbox.panel{
    ...
    widgets = {
		...
		jbox.up_down_button{
			graphics = { node = "TriggerNoteUpDownButton" },
			value = "/custom_properties/triggerNote"
		},
		jbox.value_display{
			graphics = {  -- required
				node = "TriggerNoteOutValueDisplay",
			},
			value = "/custom_properties/triggerNote",
			text_color = { 38, 152, 162 },
			text_style = "LCD font",
		}
	}


I have in my motherboard_ref.lua file:

Code: Select all

custom_properties = jbox.property_set{
	document_owner = {
		properties = {
			triggerNote = jbox.number{
				ui_name = jbox.ui_text( "text_triggerNoteOut" ),
				default = 0,
				steps = 2,
				ui_type = jbox.ui_linear( { 
					min = 0,
					max = 1,
					-- units = {{ decimals = 0 }} -- THIS WORKS FINE BUT DOESN'T USE MY CUSTOM TEXT
					units = {
						{
							decimals = 0, 
							min-value = 0, 
							unit = {  
								template = jbox.ui_text( "text_C0" ), // THIS IS "C0" IN texts.lua
								base = 1  
							}
						},
						{
							decimals = 0, 
							min-value = 1, 
							unit = {  
								template = jbox.ui_text( "text_C#0" ),   -- THIS IS "C#0" IN texts.lua
								base = 1  
							}
						}
					}
				} ),
				persistance = "song"
			}
		}
	},
	...

User avatar
orthodox
RE Developer
Posts: 2286
Joined: 22 Jan 2015
Location: 55°09'24.5"N 37°27'41.4"E

Post 18 Jun 2021

Why won't you use jbox.ui_selector instead of ui_linear? It would fit your needs better.

persistance seems to be the wrong spelling, it's persistence in the docs.

wendallsan
Posts: 45
Joined: 10 Dec 2017

Post 19 Jun 2021

thanks! I fixed my spelling error and have moved over to using ui_selector as you suggested and things are working great now.

  • Information
  • Who is online

    Users browsing this forum: CommonCrawl [Bot] and 41 guests