Device.active_preset (the index) is 0 for VST3, but 1 for VST2

Here is a debug enabled version of the tool, search for “bug here” in the main.lua:
de.fladd.SplitIntoSeparateTracks.xrnx (5.3 KB)

This code even hard-crashes / force-quits Renoise:

for d = 2, #current_song.tracks[orig_track_index].devices do
          print('grabbbing device at', d)
          local device = current_song.tracks[orig_track_index]:device(d)
          print('done grabbing')
          current_song.tracks[group_track]:insert_device_at(
            device.device_path, d)
          local new_device = current_song.tracks[group_track].devices[d]
          new_device.display_name = device.display_name
          new_device.is_active = device.is_active
          new_device.is_maximized = device.is_maximized
          local fixed_index = device.active_preset == 0 and 1 or device.active_preset
          print('copying active preset at index', device.active_preset, 'of device', device.name, fixed_index)
          -- BUG HERE
          new_device.active_preset = fixed_index
          new_device.active_preset_data = device.active_preset_data
        end

de.fladd.SplitIntoSeparateTracks-HardCrashing.xrnx (5.3 KB)

I guess because there is no index 1.

For the crash, select a VST3 device and then enter simply: