Everyone wants a pause button. I HATE it when I have to reset my game if I die.
I don't know any links for it though.
This would likely be very tricky. It'd probably be possible to just completely stop it on any frame but pausing it could present challenges. You'd have to ask @apple502j about it, but it'd be super cool!
scratch-vm probably has some way to pause itself right?
edit it used to, now it doesn't https://github.com/LLK/scratch-vm/pull/294
edit edit: vm.runtime.ioDevices.clock.pause() will pause the project timer, but i have no clue how to pause block execution
Maybe you want to find the code that sets the frame or something like what TurboWarp does to set the frames to 60. You might want to try to set it to 0.
Maybe you want to find the code that sets the frame or something like what TurboWarp does to set the frames to 60. You might want to try to set it to 0.
Unfortunately that's just a boolean, true for 30 FPS, false for 60 FPS.
Maybe you can make it so running a tick actually doesn't do anything?
Forkphorus has this, I think we could do this.
forkphorus compiles to javascript
Just override vm._step to no-op if paused, that shouldn't be hard
this sounds like a fun addon to try to make, I'll see what i can make tomorrow
alright so i've tried something like this
if (!playing) {
vm.runtime._step = step
vm.runtime.audioEngine.audioContext.resume()
vm.runtime.ioDevices.clock.resume()
img.src = addon.self.dir + "/pause.svg"
} else {
step = vm.runtime._step
vm.runtime._step = function() {}
vm.runtime.audioEngine.audioContext.suspend()
vm.runtime.ioDevices.clock.pause()
img.src = addon.self.dir + "/play.svg"
}
playing = !playing
but an issue i have is that when you resume, the audio/timer are fine, but the actual execution will jump ahead as if it was never paused. i don't know if that's something which is possible to fix.
another thing to note is with something like this, it's not possible to see variable values in the editor which is a major reason to pause projects.
griffpatch said:
What we actually need to do is pull all the execution stack out into a temporary location, and then resume it later by putting it back in
I've seen it done before
Game bender does it in a custom build of scratch all the time ;)
which means it must be possible, but i don't think that's something i know how to do...
in the meantime, i've made some nice buttons and used the replacing step with no-op to make this:
so basically i store all of vm.runtime.threads in a variable and set it to [] when paused and set it back to the variable when unpaused!
nice
Wow, this will be an awesome addon! Does this slow down performance?
@TheColaber yes because traps
@TheColaber yes because traps
Ah, that's unfortunate
@TheColaber yes because traps
Ah, that's unfortunate
not really a big deal
WOW MIND BLOWN
uh i don't think you needed to close the issue. the PR isn't merged yet lol
uh i don't think you needed to close the issue. the PR isn't merged yet lol
Sorry
Most helpful comment
Just override vm._step to no-op if paused, that shouldn't be hard