I still don't understand your question. But if you want to pause the function, then just don't call it. Check for some condition, say, use a variable - spawningIsPaused. Set it to true when you need to pause spawning.
If NOT spawningIsPaused -> Call SpawnNewMolecule
Then set it to false to resume spawning.
This works only somewhat.
Not entirely sure why, but I call the pause to happen in certain states and it doesn't function as intended. I think it may have to do with the fact that the Background sprite is the one with the timer and the instance variable of Pause, and I'm calling on booleans from other sprites to Pause, like so:
Moleks still appear even after challenge is on, but only showing from one corner. I'd rather it didn't spawn at all, if not from the Chemic itself, which I've already done separately.
If not, maybe I'm overlooking something crucial, because I also have a sequence of events happening here via function:
* On function 'Cutscene'
-> Background: Set Pause to True
-> Chemic: Set 8Direction Disabled
-> Plan: Set animation frame to 0
-> Plan: Stop animation
-> System: Wait 1.0 seconds (use time scale: True)
-> Chemic: Subtract 1 from child_count
-> Molek: Set attached to False
-> Molek: Set Bullet speed to 500
-> Molek: Set Bullet angle of motion to angle(0,0,Self.dx,Self.dy) degrees
-> Molek: Set Bullet acceleration to 0
-> Molek: Start animation from beginning
-> Molek: Set collisions Disabled
-> Chemic: Subtract 1 from child_count
-> Molek: Set attached to False
-> Molek: Set Bullet speed to 500
-> Molek: Set Bullet angle of motion to angle(0,0,Self.dx,Self.dy) degrees
-> Molek: Set Bullet acceleration to 0
-> Molek: Start animation from beginning
-> Molek: Set collisions Disabled
-> Chemic: Subtract 1 from child_count
-> Molek: Set attached to False
-> Molek: Set Bullet speed to 500
-> Molek: Set Bullet angle of motion to angle(0,0,Self.dx,Self.dy) degrees
-> Molek: Set Bullet acceleration to 0
-> Molek: Start animation from beginning
-> Molek: Set collisions Disabled
-> Chemic: Subtract 1 from child_count
-> Molek: Set attached to False
-> Molek: Set Bullet speed to 500
-> Molek: Set Bullet angle of motion to angle(0,0,Self.dx,Self.dy) degrees
-> Molek: Set Bullet acceleration to 0
-> Molek: Start animation from beginning
-> Molek: Set collisions Disabled
-> Audio: Play "Cutscene" not looping from Sounds at 0 dB (stereo pan 0, tag "")
-> System: Wait 1.0 seconds (use time scale: True)
-> Chemic: MoveTo: Move to (540, 1290) (Direct)
-> System: Wait 3 seconds (use time scale: True)
-> Audio: Play "Start" not looping from Sounds at -10 dB (stereo pan 0, tag "")
-> Background: Spawn Build on layer 6 (image point 0, create hierarchy: False, template: "")
-> Build: Set position to (180.909, 747.765109)
-> Build: Fade: start fade
-> Plan: Start animation from beginning
-> System: Wait 5.0 seconds (use time scale: True)
-> System: Save game to slot "mysave"
-> Chemic: Set 8Direction Enabled
-> Chemic: Set Cutscene to False
-> System: Wait 1.0 seconds (use time scale: True)
-> Audio: Play "World1" looping from Music at -10 dB (stereo pan 0, tag "")
-> Background: Set Pause to False
As you can see, the Pause boolean is set to false at the very end, and yet the molek shows right when the "Build" text appears and not later.