Struggling with the Execute Lua command

I’m trying to update a Group name from a Bitwig controller script. I want it to be the name of the current device on the track. I’ve created a lua script that includes this function:

-- Helper to set group label (called via SysEx from Bitwig)
function sgt(groupId, title)
    local group = groups.get(groupId)
    if group then
        group:setLabel(title)
    end
end

Then in the Bitwig controller script I’m doing that following:

    var luaCmd = 'sgt (' + groupId + ', "' + displayName + '")';
    var sysexData = 'F0 00 21 45 08 0D ' + this.str2hex(luaCmd) + ' F7';

    try {
        this.midiOutCtrl.sendSysex(sysexData);
        println("[DEBUG] Execute Lua sent to CTRL port OK");
    } catch (e) {
        println("[DEBUG] ERROR: " + e);
    }

However, I’m not seeing the group name change. Any help here would be most welcome.

The script started working. I’m not exactly sure how, but I think it was probably me not completely understanding the workflow of uploading the lua and the epr.

Hi @Songsta, the Lua is transferred along with the preset file (.epr) when you hit the “send to electra” button.

You should see the following message after the transfer of the preset files (including Lua) is completed:

That indicates that the Lua script was successfully transferred and compiled. Do you see that message there?

Thanks Martin. It came right and I’ve managed to get the Lua script working. There seemed to have been an issue with my preset slots - some preset folders on the E-1 were missing and so even though the app was telling me that the files were transferred, they were not actually on the device. I manually re-created the folders (p02,p03 etc) and this seems to have solved the problem. At least I think it was this.

1 Like

yes, it makes sense - especially in the context of other issues you mentioned recently. Pls note, you can download the factory “image” of the SD card from Downloads - if you wanted to be sure everything is in place.

Great! I didn’t of looking there for that. Thanks.