Skip to content Skip to sidebar Skip to footer

Uncaught Typeerror: T Is Undefined (p5.min.js:4604:988)

I'm trying to take user input and use it to generate some things. It works when I hardcode the inputs for the generator like this: function setup() { createCanvas(1280, 512);

Solution 1:

This line of code is the issue:

button.mousePressed(generator.draw());

This will invoke generator.draw() once and register whatever it returns as the mousePressed handler. Since you did not include the code for Room_map I can only speculate what draw() does, but I'm guessing it does not return a function object, and probably returns undefined. As a result whenever the mouse is pressed there will be an error because you cannot invoke undefined as a function. What you probably meant to do is use an anonymous function:

button.mousePressed(() => generator.draw());

Post a Comment for "Uncaught Typeerror: T Is Undefined (p5.min.js:4604:988)"