View Single Post
Old 11-12-2018, 09:13 PM   #342
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
Default

The knob (and slider, I think?)'s output property lets you format the values it displays.

Setting it to a number:
Code:
GUI.elms.my_knob.output = 5
will always show 5.

Setting it to a function will show whatever is returned by calling my_function(value). For instance, to make the knob show "dB" next to every number you would use:
Code:
local function append_db(value)
  return value .. "dB"
end

GUI.elms.my_knob.output = append_db
(One of the example scripts in the Dev. Tools package does this... I think)

Setting it to a table will show whatever value it finds in the table, using the value as a key. This is good if you want to convert the numeric value to some sort of "mode":
Code:
local knob_strings = {
  [0] = "Please don't hurt me",
  [1] = "Hey, not too rough",
  [2] = "Hurt me plenty",
  [3] = "Ultra-violence",
  [4] = "Nightmare"
}

GUI.elms.my_knob.output = knob_string
It will always pass the value through tostring afterward, so buggy output shouldn't crash the script (yay!) but you might see a bunch of nil if something goes wrong (boo!).

https://github.com/jalovatt/Lokasenn...wiki/2.00-Knob
__________________
I'm no longer using Reaper or working on scripts for it. Sorry. :(
Default 5.0 Nitpicky Edition / GUI library for Lua scripts / Theory Helper / Radial Menu / Donate
Lokasenna is offline   Reply With Quote