itami wrote:
Good day to you, dear scriptmakers! I am trying to write my first script and have a question to ask. My script is about writing lines but while playing other scripts with typing tasks I found a bug that I would like to avoid. The catch is that no one prevents the user from waiting through all the time during the first line, receiving the little time punishment and then finishing the taks with flying colours.
I tested it in Lines and Lady Gives Lines and it worked both times. I would like to implement the feature that the user is automatically directed to the punishment screen after he fails to write the line within the time limit.
I know that there is a function with a timed button, like showButton("Press quickly",60). Is it possible to use getString("Type: "+line,"") with a similar timer? If there is no such option, could you suggest any trick to deal with this problem?
Doti will confirm, but I don't think there is a function to do this (sadly, very few allow "timers"; I have been trying to do the same thing with getSelectedValue myself).
When I did "writing lines" in my
Teacher Trouble script, I did it like below:
Code:
lines = getRandom(10+1)*10
show("Now, I want you to write me "+lines+" lines.\n\nEach one should say 'I will "+offenseDesc4+"'.\n\nI expect your neatest writing, "+lastname+"!")
showButton("Yes, "+respectTitle+"")
setImageReport()
show(""+lines+" lines:\n\n'I will "+offenseDesc4+"'.\n\nLet me know when you're done, "+boygirl+".")
wait(4)
line = ""
lineWrite = "I will "+offenseDesc4+""
linesDone = 0
while(linesDone<=lines) {
loop = true
while(loop) {
line = getString("Lines Written: "+linesDone+" of "+lines+"\n\n'"+lineWrite+"'","")
if(line==""+lineWrite+"") {
linesDone ++
loop = false
} else {
show("That line doesn't count!\n\nRepeat it!")
wait(3)
}
}
} else {
linesDone = lines
show("Lines Written: "+linesDone+" of "+lines+"\n\n'"+lineWrite+"'")
}
showButton("Done, "+respectTitle+"")
The "loop" part is so that a mistake in the lines forces a repeat of that line.
I don't see why you couldn't also add a "timestamp check" before/after the loop.
Example:
Code:
def timestamp = getTime()
...
def lineTimeout = getTime() - timestamp
and then do an "if...else", example:
Code:
if(lineTimeout>lineTimelimit) {
... *punishment for being slow*
} else {
loop = false
}
So you end up with something like:
Code:
lineTimeLimit = 3
lines = getRandom(10+1)*10
show("Now, I want you to write me "+lines+" lines.\n\nEach one should say 'I will "+offenseDesc4+"'.\n\nI expect your neatest writing, "+lastname+"!")
showButton("Yes, "+respectTitle+"")
setImageReport()
show(""+lines+" lines:\n\n'I will "+offenseDesc4+"'.\n\nLet me know when you're done, "+boygirl+".")
wait(4)
line = ""
lineWrite = "I will "+offenseDesc4+""
linesDone = 0
while(linesDone<=lines) {
loop = true
while(loop) {
timestamp = getTime()
line = getString("Lines Written: "+linesDone+" of "+lines+"\n\n'"+lineWrite+"'","")
lineTimeout = getTime() - timestamp
if(line==""+lineWrite+"") {
linesDone ++
loop = false
} else if(lineTimeout>lineTimeLimit) {
-> punishment for being too slow with line goes here
} else {
show("That line doesn't count!\n\nRepeat it!")
wait(3)
-> punishment for incorrect line goes here
}
}
} else {
linesDone = lines
show("Lines Written: "+linesDone+" of "+lines+"\n\n'"+lineWrite+"'")
}
showButton("Done, "+respectTitle+"")
Keep in mind this is all just in theory and I haven't tested the code above, but the first version works in Teacher Trouble and the idea of checking against a "timestamp" on either side of a player input (button, string typed, getSelectedValue, etc.) is something I am using in a new script I've been writing and it seems to work well.