Log In  

It's a very minor issue but may be important for some carts. In the web version of PICO-8 using menuitems in the pause menu causes _update and _draw to be called.

Version: 0.2.4c4 web applet

How to replicate

Make a cart that has an _update function defined that will cause a visible change on screen. Define a menuitem with a callback that returns true so that the menu stays open after the menu item is used. Run the cart, pause it and use the menuitem.

Expected behavior

The callback runs and the state of the program is only changed in the way the callback changed it. (This is waht happens in the full desktop app version 0.2.4)

Actual behavior

A frame progresses before the callback is resolved. The calling order seems to be: _update, _draw, callback.

Examples:

Simple example:


Cart #rosoyugima-0 | 2022-05-11 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
3


Example in a real cart:
This also shows how the frame updates before the callback: changing the SNAKE setting doesn't affect the incorrect frame update and only takes effect the next frame.


Cart #speedsnake_ai-9 | 2022-05-11 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
12


P#111661 2022-05-11 08:38 ( Edited 2022-05-11 08:41)

Yep, I came across this earlier myself, @olus2000. I was actually elated to see it did this online but then disappointed to see it would not work offline.

Still to maintain continuity, both the offline and online versions should run exactly the same, @zep.

P#111700 2022-05-11 20:18

I don't see any reason for such reaction. This is clearly undesired behavior! The user has paused the cart and takes their time to change the settings. That is the worst time to call _update! If the callback is supposed to update the program state it can just do so in its body, and if it needs to update the screen it can just call flip! And if the callback is literally supposed to just call _update and _draw it can easily do so with code, in a manner controlled by the programmer. Calling the frame callbacks BEFORE the menuitem callback is the worst way to achieve this behavior and I can't see a clean way to circumvent it.

Wow, that was a rant!

P#111702 2022-05-11 20:29 ( Edited 2022-05-11 20:29)

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-03-28 11:47:07 | 0.028s | Q:24