Cabbage Logo
Back to Cabbage Site

Logging cabbagecodescript from plant

Is there a simple way to dump what is generated in between JS? I can’t really think of one. I’m trying to debug what is generated.

cheers

Oh wow, someone is actually using this feature :grimacing: Just kidding, but I think you might be the first! No easy way to print the output as of yet. I guess you could just copy and paste to an online JS compiler?

Hehe! It’s pretty much the least labour intensive way to build and maintain my gui, so it’s great in that respect, but the concept took a bit to get my head around.

Indeed that is a clever idea, only that Cabbage.print is not defined, I would have to refactor the code to work around that…tho I could create a mock Cabbage object ughhhh yayayay

I ended up resorting to the tooltip text which displays the channel string, though my widget was nslider, which doesn’t display one. Took me a while to figure that one out :wink:

Just swap out the Cabbage.print() with console.log

[puts hood on and walks away surreptitiously]

:sweat_smile:

Sorry I have to ask… what is cabbagecodescript ?

A custom plant xml file has a <cabbagecodescript> section where you can use Javascript to generate your Cabbage GUI. This can be useful for creating plants with lots of widgets. For example, the following code (taken from the manual) create a 8x16 matrix that you might see in a step sequencer:

 var channelNumber = 1;
Cabbage.print("image bounds(10, 10, 360, 178) colour(0, 0, 0, 0){");

for(var y = 0 ; y < 8 ; y++)
{    
  for (var x = 0 ; x < 16 ; x++)
  {
  if(y==0)
    Cabbage.print("image bounds("+((x*22))+", 0, 23, 176), colour(100, 100, 100), identchannel(\"scrubberIdent"+(x+1)+"\")");

  Cabbage.print("checkbox bounds("+x*22+","+y*22+", 20, 20), colour(\"red\"), channel(\"gridChannel"+channelNumber+"\")");
  channelNumber++;
  }
}
Cabbage.print("}");

Although custom plant imports seem to work quite well for instruments hosted inside of Cabbage, they are relatively untested in the wild. Mileage may vary.

1 Like