How does builder.connectToScript() work?
-
I have this code:
inline function build_midi_script_processors() { for (i = 0; i < max_count; i++) { local script_processor = builder.create( builder.MidiProcessors.ScriptProcessor, "script_processor_" + i, i+1, builder.ChainIndexes.Midi); builder.connectToScript(script_processor, "{PROJECT_FOLDER}/Scripts/ScriptProcessors/ghostalpha2/sampler_scriptprocessor_template.js"); } }
But I get this in response:
script_processor_0:! onControl could not be parsed! script_processor_1:! onControl could not be parsed! script_processor_2:! onControl could not be parsed! script_processor_3:! onControl could not be parsed! script_processor_4:! onControl could not be parsed! script_processor_5:! onControl could not be parsed! script_processor_6:! onControl could not be parsed! script_processor_7:! onControl could not be parsed! script_processor_8:! onControl could not be parsed! script_processor_9:! onControl could not be parsed! script_processor_10:! onControl could not be parsed! script_processor_11:! onControl could not be parsed! script_processor_12:! onControl could not be parsed! script_processor_13:! onControl could not be parsed! script_processor_14:! onControl could not be parsed! script_processor_15:! onControl could not be parsed!
I've tried all manner of different paths to the script, and nothing seems to be working.
The script template itself is:
function onNoteOn() { Console.print('onNoteOn method'); } function onNoteOff() { Console.print('onNoteOff method'); } function onController() { Console.print('onController method'); } function onTimer() { Console.print('onTimer method'); } function onControl(number, value) { Console.print('onControl method'); }
-
@Christoph-Hart Could this be a bug? I followed the instructions on this page:
https://docs.hise.audio/scripting/scripting-api/builder/index.html#connecttoscript -
Still finding issues with this. Anyone got a snippet that demonstrates connecting to a script via Builder.connectToScript ?
-
Same issue. Perhaps related, this also is not working:
var test = builder.create(builder.MidiProcessors.ScriptProcessor, name, parent, builder.ChainIndexes.Midi)
builder.setAttributes(test, {"Bypassed": 0, “Script”: #script contents# } );
test becomes an object 0xEtc reference, but nothing can be set to it from setAttributes. I’m just wondering if both issues are related in a backend method.
This method used to work in one of the 3.x versions, sorry I can’t be of more detail
-
@Fergler yeah you can use this method with float attributes only.
The connectToScript function is almost correct, but the reference does need to use the Scripts folder in its path:
{PROJECT_FOLDER}ScriptProcessors/MyProcessor.js
should work, however it‘s highly recommended to move the script out of this directory as it will be replaced on the next save.