I have a few more GUI questions

I've been defining a few classes, but within the class functions I'm not able to call p5 functions or other custom classes, because they are apparently "undefined". Do I have to keep them external or is there a way to store them as class members?

class Space {
	constructor() {
		this.x = 0;
		this.y = 0;
		this.specIn = createInput('0'); // Uncaught ReferenceError: createInput is not defined
	}
}

Edit: I found this: https://github.com/processing/p5.js/wiki/p5.js-overview#instantiation--namespace but on-deman global mode and instance mode don't seem to play well with loadScript and loadImage which are Bela functions I'm guessing that are intended to be added to the p5 object.

Also on the subject of the data Buffers, are the same bufferIDs used for both Bela-to-GUI and GUI-to-Bela communication? For example if I use

// C++
gui.sendBuffer(0, data)

// JavaScript
let data = Bela.data.buffers[0];

and also

// javascript
Bela.data.sendBuffer(0, 'float', buffer);

// C++
gui.setBuffer('f', 2);
DataBuffer& buffer =  gui.getDataBuffer(0)

in the same project, would that be the same buffer 0 or would they be different because one is sent from the bela and one is sent by the gui?

    RyanGo Also on the subject of the data Buffers, are the same bufferIDs used for both Bela-to-GUI and GUI-to-Bela communication?

    No, the ID is unique to the direction (Bela->GUI or GUI->Bela). To send from Bela to the GUI, you can send whatever ID and whatever length, those will be safely received on the GUI side, where you'd handle them as you wish. To receive on Bela from the GUI, you have to pre-allocate the buffer with setBuffer(). Then from the GUI you should send data of the correct type, and up to the specified length. Data of the wrong type will be discarded and data exceeding the pre-allocated length will be trimmed to length.

    Note that Gui::setBuffer() needs to be called from setup(), as it is not real-time safe.

    RyanGo but within the class functions I'm not able to call p5 functions or other custom classes, because they are apparently "undefined".

    I am wondering if you have to call them after or within setup() ? @adanlbenito will know best.