All,
i have this function that works when I place it in the function section of a fader but not when i add a lua function the the sysex editor. it seems like the valueObjects aren’t passed to the function?
function default(valueObject, value)
local default = valueObject:getDefault()
print ("default"..default)
if default ~= value then
valueObject:setDefault(value)
print("value" ..value)
end
If you define a function in Lua, you have to tie it to a control by placing its name in the format or function area of the web UI when editing the control.
valueObjects are definitely passed to the function otherwise most of the presets on line would not work.
Like I said it does work when placed in the function section of the fader but I can’t return a value to the sysex section of the fader I don’t believe. Still new to all this. I do place the function call in the sysex editor tho which doesn’t seem to work. I did try have it in both location and it still failed.
This is what I get when the call is from the sysex edit sysex data section. changed the names to getdefault.
error running function ‘runTemplateFunction’: ctrlv2/slots/p011.lua:3: attempt to call a nil value (method ‘getDefault’)
Wouldn’t a nill mean that data isn’t being passed?
I don’t know if its the type change to sysex.
the function is placed different in the json.
}
],
“values”: [
{
“message”: {
“type”: “sysex”,
“deviceId”: 1,
“data”: [
“00”,
{
“type”: “function”,
“name”: “senddefault”
}
],
“parameterNumber”: 1,
“min”: 0,
“max”: 127
},
“defaultValue”: 100,
“id”: “value”
}
]
}
]
}
ok. I have never used the sysex editor in the web UI, so I’m going to have to let someone else speak up here. In theory it should work the same no matter where you invoke the function, but the error message is indicating that the valueObject is not instantiated if the function is invoked from the sysex editor which is a bit weird.
I believe no valueObject is passed to a function in the Sysex editor. AFAIK I 've always been able to work around that.The obvious reason to me is lua does not know what valueObject it should refer to when the function is invoked from a Sysex json.
When I need context aware Sysex , it do not use the Sysex editor nor Sysex parameters. In such case it is easier to create Virtual parameters, combined with parameterMap.onChange and midi.sendSysex. Then you have all context available and no need to retype any Sysex json per parameter.