Closed villares closed 2 years ago
Finally have this fixed!
The code behind the setup()
magic is a delicate balance between reworking the code to create new settings()
and setup()
functions and proper error messages. A lot of work has gone into making sure py5's error messages point to the user's code with the correct line numbers when an exception is raised. This is difficult to achieve because the actual code that is executed is different from what the user wrote. All of this needs to work correctly for py5bot and run_sketch in addition to regular sketches, as you did in your example.
Fixing this gave me a chance to revisit the code for this and simplify things. I uncovered a bunch of other hidden problems (or perhaps I stirred up new problems with my first attempt at a fix). In any case, the code is simpler now and seems to work correctly for everything I throw at it.
Related to: https://github.com/hx2A/py5generator/issues/40
Sometimes, not always,
global
statements don't work insetup()
.Minimal example using imported mode:
Result: