Python code Resume scene not working. Help, please?

I’ve got a simple setup for a pause menu. I need it so the pause works well from ANY scene/level and prefferably with mouseclicks on certain menues. I tried it first with simple key.It properly adds/removes the overlay scene but does NOT resume the current paused scene .I wanted to merge it in one script. Something like if currentscene is “pause” and “P” is pressed resume paused scene but my python is bad so it uses 2 scripts.Here is the pause one:

from bge import render, logic, events

keyboard = logic.keyboard.events

if keyboard[events.PKEY]:
scene = bge.logic.getCurrentScene()
scene.suspend()
bge.logic.addScene(“Pause”, 1)

and here the Unpause:

from bge import render, logic, events

keyboard = logic.keyboard.events

if keyboard[events.PKEY]:
scene = bge.logic.getCurrentScene()
scene.resume(“Scene”)
scene.end()

And the blend : pause_tests.blend (507 KB)
I’ll be thankfull for any working solution

Well, I tried my hand at something. Its been awhile since I coded for the bge so I’m a bit rusty :slight_smile:

Here it is:
pause_tests.blend (573 KB)

Its all in 1 file, I used functions to let the different objects call the different parts of the code.

Hope it helps
Ex.

That part was the thing I didn’t know how to do:
main_scene = [scene for scene in scn_list if “Scene” in scene.name][0]
pause_scene = [scene for scene in scn_list if “Pause” in scene.name][0]
So I couldn’t call the resume of the main scene.Now it works correctly.
One small problem remains. After you’ve paused you have to press “P” TWICE to unpause. I have no idea why it does so.