LUA-created groups are not usable

Hello,
I’m writing a script to setup some buses in a session. It also creates groups for each bus and sets some defaults and colors. But, the LUA created groups are not usable. The buses are in the group, but not really?

image

I cannot assign other tracks to the groups, I can drag the group over another track, but the track doesn’t actually get assigned to the group. Another scripthook doesn’t react to the track getting added to a group.

        local function getRouteGroup(group)
            assert(group)

            print("Creating group " .. group.name)

            local current_routegroup = Session:new_route_group(group.name)

            current_routegroup:set_color(false)
            current_routegroup:set_gain(false)
            current_routegroup:set_relative(false, nil)
            current_routegroup:set_hidden(false, nil)
            current_routegroup:set_monitoring(false)
            current_routegroup:set_mute(false)
            current_routegroup:set_recenable(false)
            current_routegroup:set_rgba(catppuccin[group.color])
            current_routegroup:set_route_active(true)
            current_routegroup:set_select(false)
            current_routegroup:set_solo(false)

            return current_routegroup
        end

I can create another group with the same name (eg. second group “Strings”), when running the script the second group is used in the script.

What’s the correct way to create a routegroup with LUA?

Thanks and best!
Vivien

In ardour/share/scripts/track_organizer.lua at 6cc89c847048026f1494fda9d0c37a86c15c7518 · Ardour/ardour · GitHub there is a Session:add_route_group() function used, but it’s not in the documentation and doesn’t work in my console:

group = Session:new_route_group("Strings")
Session:add_route_group(group)

Error: [string "group = Session:new_route_group("Strings")..."]:2: attempt to call a nil value (method 'add_route_group')
group = Session:new_route_group("Strings")
group:add(Session:route_by_name("Strings"))

works in Ardour 8.12, broken in 9.2, just creates new broken route_groups when run in the console.

I’m still doing something wrong here, I guess :frowning: