Is there a way to create a new instance of a darkroom module in darktable using lua?
My first suspect would be darktable.gui.action, but unfortunately the documentation is scarce for this function and I cannot figure out which element or effect could do the trick.
The easiest way to find the parameters to use for dt.gui.action is to create a shortcut that does what you want (selecting the correct element and effect from their dropdowns in the shortcuts dialog or preferences tab), then select the shortcut and press ctrl+c. This puts the lua command on the clipboard so you can paste it in your script editor.
You can also see the lua command for a visible widget (for example the module’s “instance” button) in its tooltip when you switch on shortcut mapping mode and then a long right-click copies it. But that is only useful for default elements/effects; it doesn’t offer a way to find all available options.
That’s a very useful feature, but unfortunately, when hovering over the instance button in shortcut mapping mode, only dt.gui.action("iop/exposure", "instance", "show", 1.000, 0) is shown as example, not the other possible actions.
Is there also a way to rename the new instance? I got as far as dt.gui.action("iop/exposure", 0, "instance", "rename", 1), which makes the instance’s name editable, but I still need to put the new name by hand.