This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2013-02-12 17:20:08

harveyleigh
New Scratcher
Registered: 2013-02-10
Posts: 1

Time to Answer - Help

Hi there,
I think this must be obvious but it hasn't clicked

I want the script to ask the user a question and to offer them a fixed time to answer (say 5 seconds). If they do answer within 5 seconds then fine. If not then another action.

I can set a timer and do conditional tests which is fine but how do I cope with the open ended ask operator?

Offline

 

#2 2013-02-12 18:47:48

andre_rifaut
New Scratcher
Registered: 2012-12-09
Posts: 1

Re: Time to Answer - Help

harveyleigh wrote:

Hi there,
I think this must be obvious but it hasn't clicked

I want the script to ask the user a question and to offer them a fixed time to answer (say 5 seconds). If they do answer within 5 seconds then fine. If not then another action.

I can set a timer and do conditional tests which is fine but how do I cope with the open ended ask operator?

You have different choices:
1) one possibility is to capture key strokes and display them in a variable.
2) another possibility is to capture key strokes and stamp them on the background by using a sprite having all costumes of letters

With Scratch 2.0 in addition to "stop this scipt" and "stop all scripts" you can also use "stop the other scripts". I made a test srcipt in http://beta.scratch.mit.edu/projects/10046384/

This works, but when ending the script using "ask", the input widget is not removed from the screen, but is no longer active ! (Bug or feature ?) When answering to the next question, one must first remove the preceding input widget.

Offline

 

#3 2013-02-12 18:58:25

ErnieParke
Scratcher
Registered: 2010-12-03
Posts: 1000+

Re: Time to Answer - Help

Well, andre_rifaut's method would work finely, except that'd be in Scratch 2.0, which I don't think tat you want to do this in. So, another method that I might as well point out is this:

when gf clicked
set [Answered? v] to (1)
broadcast [Broadcast v]
wait (5) secs//Wait
if <(answer) = []>//That is a blank.
 set [Answered? v] to (0)
 broadcast [Broadcast v]
end
when I receive [Broadcast v]
if <(Answered?) = (1)>
 ask [What do you want to say?] and wait
end

I hope that this helps!

Last edited by ErnieParke (2013-03-11 15:06:00)


http://i46.tinypic.com/35ismmc.png

Offline

 

#4 2013-03-11 13:51:57

vijer
New Scratcher
Registered: 2013-03-05
Posts: 2

Re: Time to Answer - Help

And how would you ensure answer is blank?  Lets say that you first ask for the users name, now answer has a value. Next step you want the user to answer another question in 10 seconds but answer already has a value and you cannot assign a value or reset it like you can with the timer.

Offline

 

#5 2013-03-11 15:08:14

ErnieParke
Scratcher
Registered: 2010-12-03
Posts: 1000+

Re: Time to Answer - Help

vijer wrote:

And how would you ensure answer is blank?  Lets say that you first ask for the users name, now answer has a value. Next step you want the user to answer another question in 10 seconds but answer already has a value and you cannot assign a value or reset it like you can with the timer.

Well that is true because the method that I showed above was meant to be a one-time-work script, though you could always introduce a new variable and use that as your answer, giving you unlimited uses.

With regards,

ErnieParke


http://i46.tinypic.com/35ismmc.png

Offline

 

Board footer