Log In  

Let's say I have a cartridge that changes game states by swapping out the _update and _draw functions. This way, when I'm at the title screen, the title screen's _draw function is called directly, as it is stored in the global variable named "_draw", and when I switch to the in-game state, the level drawing function moves to "_draw" instead. This reduces logic (and therefore saves precious characters / tokens) since you no longer need to call the function yourself based on what gamestate you're in.

Now, one of those game states is transitional. It doesn't need an _update or _draw function. It exists entirely as an _init function that draws and flips itself for a bit, then changes the gamestate to something else. But since Pico-8 knows that there was an "_update" function before, it still remembers that and tries to call it...

... Which crashes the program script with a Lua error saying that it failed to call _update on a line beyond the end of the program. Fun! :D

I can of course work around this just fine. In fact, with a full implementation I'm sure this problem wouldn't even exist, since flip() would presumably skip the _update and _draw calls until it's done. But this is still a thing worth noting... somewhere. Probably. ^^;

Test cart:

Cart #16138 | 2015-11-03 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA

P#16139 2015-11-02 20:26 ( Edited 2015-11-03 01:26)


[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-03-28 16:35:12 | 0.013s | Q:14