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
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
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
Last edited by ErnieParke (2013-03-11 15:06:00)
Offline
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
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
Offline