hi hi! hope the weekend went well 
just getting back into daily scripting after a weird break (hospital, etc), but i think i found some workable examples. hope these help!
yes!
in this example:
- i create two groups and hide the first at script launch
- using the
params.lookup
table, i find the ID of the hidden group and use it to toggle hidden status with K3
- remember to include
_menu.rebuild_params()
after hiding or showing a parameter!
function init()
params:add_separator("test script")
params:add_group("group 1",3)
for i = 1,3 do
params:add{
type = "option",
id = "example "..i,
name = "parameter "..i,
options = {"hi","hello","welcome"},
default = i
}
end
params:add_group("group 2",3)
for i = 1,3 do
params:add{
type = "option",
id = "another example "..i,
name = "parameter "..i,
options = {"farewell","see ya","bye"},
default = i
}
end
params:hide('group 1')
group_1_id = params.lookup["group 1"]
end
function key(n,z)
if n == 3 and z == 1 then
if params.hidden[group_1_id] then
params:show("group 1")
else
params:hide("group 1")
end
_menu.rebuild_params()
redraw()
end
end
function redraw()
screen.clear()
screen.move(64,32)
if params:visible(group_1_id) then
screen.text("group 1 visible")
else
screen.text("group 1 hidden")
end
screen.update()
end
yes, with some gotchas!
renaming a parameter requires tracking the parameter ID, which we did in the previous example with group_1_id = params.lookup["group 1"]
, to find its position in the params.params
table and change its name
entry. however, the params.lookup
table is string-indexed, built using the names we give our parameters upon creation (for example, when we create a params group). at this time, there aren’t any baked-in utilities for renaming a params item which would automatically update the params.lookup
table, though. so, we just need to be careful when/how we use the lookup and whether use that string for other params actions.
for example, params:show
can accept either a string (which it will lookup to find the ID) or a lookup ID, so if my script is set up with:
params:show("group 1")
and i change the visible name of “group 1” to “blah blah blah”, but i don’t also update the lookup table, then even though it shows as “blah blah blah” in the UI menu, it’ll always be known as “group 1” to the params system and this will error out:
params:show("blah blah blah")
…because “blah blah blah” doesn’t have a params.lookup
entry.
here’s an example which builds off the previous and accounts for these gotchas / tries to mitigate weirdness:
function init()
params:add_separator("test script")
params:add_group("group 1",3)
for i = 1,3 do
params:add{
type = "option",
id = "example "..i,
name = "parameter "..i,
options = {"hi","hello","welcome"},
default = i
}
end
params:add_group("group 2",3)
for i = 1,3 do
params:add{
type = "option",
id = "another example "..i,
name = "parameter "..i,
options = {"farewell","see ya","bye"},
default = i
}
end
params:hide('group 1')
group_1_id = params.lookup["group 1"]
group_1_name = "group 1"
end
function key(n,z)
if n == 3 and z == 1 then
if params.hidden[group_1_id] then
params:show(group_1_id) -- params:show and params:hide can accept either a string ID or a numeric ID
else
params:hide(group_1_id)
end
_menu.rebuild_params()
elseif n == 2 and z == 1 then
rename_group_1()
end
redraw()
end
function rename_group_1()
params.params[group_1_id].name = "group "..math.random(2,100) -- assign "group 1" a new name
params.lookup[group_1_name] = nil -- remove the previously-named entry from the lookup table
params.lookup[params.params[group_1_id].name] = group_1_id -- and replace it with the new name + give it the persistent ID
end
function redraw()
screen.clear()
screen.move(40,32)
if params:visible(group_1_id) then
screen.text(params.params[group_1_id].name.." visible")
else
screen.text(params.params[group_1_id].name.." hidden")
end
screen.update()
end
no, but hiding should get you in the same neighborhood of “parameters which shouldn’t be useable unless some other condition is met.” please lmk if hiding doesn’t get you where you need to go!