Is there any way for me to "pause" a timer? I'm making a game where the score is based off of a timer, and I don't want someone to cheat by pausing the game and letting the timer add to their score unfairly. I've tried making something like this, but it won't work:
when I receive [Paused v] if <(paused) = [true]> set [remember timer v] to (timer) set [Score v] to (Score) else set [Score v] to ((round (timer)) + ((Enemies killed) * (5)) endAck! Now even the scratchblocks aren't working! Oh, well. At the bottom, it's supposed to say ((round (timer)) + ((Enemies killed) * (5)).
Last edited by Zangooser (2012-08-18 21:21:33)
Offline
dont use the normal timer, it goes on constantly. Instead use this
when gf clicked forever if <(paused) = (0)> change [timer v] by (0.1) wait (0.1) secsand when you pause set "paused" to 1, and when you unpause set it to 0
Offline
Zangooser wrote:
Is there any way for me to "pause" a timer? I'm making a game where the score is based off of a timer, and I don't want someone to cheat by pausing the game and letting the timer add to their score unfairly. I've tried making something like this, but it won't work:
when I receive [Paused v] if <(paused) = [true]> set [remember timer v] to (timer) set [Score v] to (Score) else set [Score v] to ((round (timer)) + ((Enemies killed) * (5))) endAck! Now even the scratchblocks aren't working! Oh, well. At the bottom, it's supposed to say ((round (timer)) + ((Enemies killed) * (5)).
Does anyone have any suggestions as to how I could attempt this?
Fixed.
Other than that, my only suggestion is to do what zammer990 told you to do. Sorry about not constructively adding to the conversation.
Last edited by ErnieParke (2012-08-18 19:26:11)
Offline
No, you shouldn't do what zammer990 said, because due to the scratchblocks delay, it'll be way off. What you should do is this:
when gf clicked set [timer v] to [0] forever if <not<(paused)=[1]>> reset timer wait until <<(timer) > (1)>or <(timer) = [1]>> change [timer v] by (1) end
Offline
TorbyFork234 wrote:
No, you shouldn't do what zammer990 said, because due to the scratchblocks delay, it'll be way off. What you should do is this:
when gf clicked set [timer v] to [0] forever if <not<(paused)=[1]>> reset timer wait until <<(timer) > (1)>or <(timer) = [1]>> change [timer v] by (1) end
I noticied that, but I hadn't thought of this script. I'm still learning.
Offline
ErnieParke wrote:
TorbyFork234 wrote:
No, you shouldn't do what zammer990 said, because due to the scratchblocks delay, it'll be way off. What you should do is this:
when gf clicked set [timer v] to [0] forever if <not<(paused)=[1]>> reset timer wait until <<(timer) > (1)>or <(timer) = [1]>> change [timer v] by (1) endI noticied that, but I hadn't thought of this script. I'm still learning.
you could also do increments of 0.5 instead of 1, to make it be a little more exact, because someone could still get 1.9x the point by skillfully pressing pause at the right moment every second.
Offline
TorbyFork234 wrote:
ErnieParke wrote:
TorbyFork234 wrote:
No, you shouldn't do what zammer990 said, because due to the scratchblocks delay, it'll be way off. What you should do is this:
when gf clicked set [timer v] to [0] forever if <not<(paused)=[1]>> reset timer wait until <not <(timer) < [1]>> change [timer v] by (1) endI noticied that, but I hadn't thought of this script. I'm still learning.
you could also do increments of 0.5 instead of 1, to make it be a little more exact, because someone could still get 1.9x the point by skillfully pressing pause at the right moment every second.
Just to let you know, you could have shortened the script a bit. Just look above. ^^
Offline
My suggestion would be to do this:
1) Use the timer (its more exact).
2) Record the time paused for.
set [delay v] to (0) reset timer repeat until <(game) = [over]> if <(paused) = [true]> set [start v] to (timer) wait until <(paused) = [false]> set [delay v] to ((delay) + ((timer) - (start))) end end end when gf clicked forever if <(paused) = [true]> set [timer v] to ((timer) - (delay))
Last edited by Prestige (2012-08-20 07:07:12)
Offline