How to post a CC event?

The only reason I wanted this is because I’m trying to work with a modulation matrix parameter that as far as I know cannot be directly linked as a parameter from a macro page.

In that case you could also look into defineModulation and calcModulation.
You can try something like this:

defineParameter("Vibrato", nil, 0, 0, 127, 1)
defineParameter("CC", nil, 0, 0, 127, 1)

defineModulation("VibratoMod", false)

function calcModulation()
  return Vibrato / 127
end

function onController(event)
  if event.controller == CC then
    Vibrato = event.value
  else
    postEvent(event)
  end
end

The Vibrato parameter is used as a modulation source.

I also notice that events posted via this runSync method don’t seem to get picked up by the same script’s onController() process, but that’s ok. It might get picked up by onUnhandled() events if I need it in the future, but I haven’t had a chance to check that yet.

Yes, you’re right. Midi events created by script module itself are not picked up by onNote, onController… of the same script module. It only picks up midi events coming from outside.

But if you had two Lua Script modules then the second script module would pick up events created by the first module.