Discuss Scratch

bcphysics
Scratcher
3 posts

countdown timer on ask and wait

Hello,
My son and I are designing a math game. We are trying to implement a timer, so when a question comes up the person has a set time to answer. I can't figure out an elegent way to pull this off. We have a timer that counts down to zero, and can do different things once the timer hits zero. However, nothing happens until the ask question is answered. This is the “wait” part of the ask and wait. I believe there could be a way to stop all, but I'm looking for other ideas on how to get the wait to terminate once the timer reaches 0.

Here is an example project: http://scratch.mit.edu/projects/26704820/


thanks
Doug

Last edited by bcphysics (Sept. 14, 2014 07:17:09)

drmcw
Scratcher
1000+ posts

countdown timer on ask and wait

The ask block can only be stopped by the user. The only programmatic way to end an ask box is the stop all which defeats the point here. Either just wait for the user to enter something and tell them they were out of time or don't use the ask box, write your own version e.g http://scratch.mit.edu/projects/19204741/

Last edited by drmcw (Sept. 14, 2014 07:51:10)

epicsandwich123
Scratcher
100+ posts

countdown timer on ask and wait

hi, i can't garuntee this will work but someone posted it on my discussion

defineaskstringandwaituntilbooleansetTo asktostringbroadcastaskwaituntilbooleanwhenIreceiveaskaskaskandwait

It will be very useful to have a block like this Perhaps I could have your advice on that?
stickfire-helper
Scratcher
24 posts

countdown timer on ask and wait

You could try having only two scripts in the sprite which asks the question:
broadcastcount downaskquestionandwaitifanswer=correctanswerthenscriptforifansweriscorrectelsescriptforifanswerisincorrectwhenIreceivecount downresettimerrepeatuntiltimer>timeallowedsettime remainingtotimeallowed-timer this is so you can display the time remaining easilystopother scripts in sprite this will cancel the ask blockscriptforifanswerisincorrect
drmcw
Scratcher
1000+ posts

countdown timer on ask and wait

stopother scripts in sprite
will not stop an ask block only stop all will. I'm afraid both solutions won't solve the problem as mentioned before.
theonlygusti
Scratcher
1000+ posts

countdown timer on ask and wait

Here ya go:

whenclickedsetanswered? Vto0ResettimerAskandwaitsetanswered? Vto1whenclickedwait0.001secssetfailto0Waituntiltimer>timelimitoranswered?=1Ifnotanswered?=1>>thensetfailto1resettimerstopallWhentimer>0.1Iffail=1thenSayyou didn't answer the question in timefor2secs
bcphysics
Scratcher
3 posts

countdown timer on ask and wait

Thanks.

How did you get the list “answered?” into the set block for variables/lists? I only see how I can use the set block with existing variables.

cheers

Last edited by bcphysics (Sept. 21, 2014 03:12:36)

bcphysics
Scratcher
3 posts

countdown timer on ask and wait

And where did the block with “answered? = 1 >> then” come from?

thanks
TheCoolGuy555
Scratcher
2 posts

countdown timer on ask and wait

Well, I think this will work., Or maybe not.
whenclicked
setTimerto5

Then this is the timer. Make it change by -1 overtime after a second. Then, also set it back the 5 seconds…
One example:
changeTimerby-1

…and continue taking away seconds.
ScratchModelMaker
Scratcher
100+ posts

countdown timer on ask and wait

Here ya go, I reviewed your project and saw the problem,

whenclickedsetanswersto settimerto repeatuntil(timer)>5 oranswer=9 broadcastChangeTimeraskWhat is 6 + 3andwaitifanswer=9 thensaycorrectelsesaywrong

Broadcast Changetimer:

whenIreceiveChangeTimerrepeatuntil(timer)>5 oranswer=9 wait1secschangetimerby1

Check if timer is over 5 already,

whenclickedforeverif(timer)>5 thensayYou didn't answer in timefor2secsstopall

Powered by DjangoBB