Error : "n is not a function"

Hello,

I’ve translated in P5js with Gemini IA a big sketch written in Java to test if it was possible.

It almost works with some modifications.

But I still have an error : “Uncaught type error : n is not a function (p5.min.js:2")”

I don’t know if it’s related but I don”t have some things I write on the console in the Java version

Well I’m stuck here ! I don’t understand at all this error !

:upside_down_face:

W/o code, no idea. Anyways, for debugging, don’t use the “.min.” version!

Grab the non-minimized version instead: https://Unpkg.com/p5/lib/p5.js

ok, done (thanks)

Now, I have

:face_in_clouds: … and it almost doesn’t work anymore !

P.S. I may try to replace the part I suspect (where I write to the console) with an old version I wrote myself (I think I didn’t change this part since). Gemini may not have done a good job on it

Gemini did not write a ‘let’ for many variable declarations. It is perhaps this that causes problems because if variables that must be local are declared as global, it will work in most cases… but not all!

I”m going to try again with Gemini,

see :

Thank you to everyone: it feels good to no longer be completely alone on my project!

:beating_heart:

I’ve redone it with Gemini with this prompt

Do the translation from Processing to P5JS of the code following line:
// DEBUT CODE
Translate only the syntax (do not change the code, do not modify the functions except for the functions of P5js, do not add functions)
Do not add or edit comments.
Precede the declarations of new variables (those that are preceded by a variable type name in Java such as String, float, Boolean, PFont, PImage, int …) with the JavaScript instruction let
For file uploads, precede the filenames with their path, namely:
data/
Use the strict javascript mode.
The part of the code located between the line
//---------------- JS debut-------------
and the line
//---------------- JS Fin-------------
is not to be translated because it is already in P5js
Variables declared in java but not initialized to a value must be declared and initialized to the null value.

// DEBUT CODE

and all the code here

And…

… and it works fine without strict mode with just a function name to change

no error

With strict mode

just an error but it”s mine because it is in the JS part !

Fixed!
Everything works without error in strict mode everywhere!!!

:grinning_face:

I’m so glad !

We can use AI for transpilation sometimes to save time.
(provided that it can also be done without!)