Run a function before pausing

image
Can I schedule a callback right before the menu opens and after it closes? When it pauses, it breaks a part of my game, but I think I know how to fix it.

No way to do this right now, but maybe it’s something we should do… If you add a button handler for the menu it will disable the built-in one.

1 Like

Maybe at least expose it in JS so someone could write an extension to do that?

How about something like this?

controller.menu.onEvent(ControllerButtonEvent.Pressed, function() {
    // do stuff before system menu
    scene.systemMenu.showSystemMenu()
    // do stuff after system menu
})
3 Likes

yep, that would work!

1 Like

Yes! It works! Thanks :pray:

Also, if anyone else needs to do the same like me and have JS commands in blocks, this is what I do:
THIS ONLY WORKS IF YOU USE GITHUB INTERGRATION

  1. Commit to GitHub.
  2. Go to JS.
  3. Type the command you need.
  4. Go back to blocks.
  5. If the layout isn’t messed up, nice! If it is, keep going.
  6. Select the JS block and press ctrl + c
  7. Revert all changes.
  8. Press ctrl + v.
  9. The block should be somewhere!
1 Like