I am asking this because the code I make is basically functions inside functions inside functions inside functions and I just think it makes the code really messy.
If it works for you, it's fine. There's really no right or wrong when coding for Pico-8, just personal preference. I myself create functions when I'm going to need the code to be repeated multiple times on different contexts. For example, I create a function to draw sprites for my game objects, so instead of doing something like this:
draw sprite for obj1
draw sprite for obj2
draw sprite for obj3
draw sprite for obj4...
I do this:
for s in all(objects) do
and "drawsprite" would do everything I want to with those game objects sprites. That way, I avoid repeating myself in code and all I have to do is make sure the objects I want to draw are in the same table (the "objects" table, in this case).
That's how I decide when to create a function or not.
[Please log in to post a comment]