de en es fr
Let the machine help
Light teasing, exhibition, BDSM, sissyfication, watersports... with sounds and pictures


Post new topic Reply to topic  [ 6 posts ] 
Author Message
 getString with a timeout. Is it possible?
PostPosted: Wed Jul 13, 2016 10:38 am 
Offline
Active member
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?


Top
 Profile Send private message 
 
 Re: getString with a timeout. Is it possible?
PostPosted: Wed Jul 13, 2016 12:10 pm 
Offline
Veteran
User avatar
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.


Top
 Profile Send private message 
 
 Re: getString with a timeout. Is it possible?
PostPosted: Wed Jul 13, 2016 1:33 pm 
Offline
Active member
Banjo wrote:
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.


Thanks a lot, Banjo. I will try to use this, just need some time to think it over and test a few hundred times.

By the way, your scripts are great, keep it up :)


Top
 Profile Send private message 
 
 Re: getString with a timeout. Is it possible?
PostPosted: Thu Jul 14, 2016 10:37 am 
Offline
Active member
Unfortunately this method doesn't work for my script. You have the condition for user to write a certain number of lines in order to finish the loop, but in my case it's just timer with added time as a penalty. So I cannot interrupt the getString function if the time limit ends, just punish after the line is written.

But I found alternative solution - counting the lines written in the end and comparing them with the time limit and total time. So if in the end the user happens to have less than half lines written than he should have on the basis of his time and limit, he gets severily punished.

But this rises another question. Is there a function which 'teleports' the progress at a certain position in the script?

Like, i have the following script

//some introduction

starttime=getTime();

while(starttime+time>getTime())
{
//Line writing
}

//Cheat check
cheat = time / timelimit
if (counter < cheat / 2){ show("You are cheating"); return null;} else {openCdTrays()}

Is this a way in the end instead of stopping the script teleport the cheater to the beginning of the while loop?


Top
 Profile Send private message 
 
 Re: getString with a timeout. Is it possible?
PostPosted: Thu Jul 14, 2016 11:10 am 
Offline
Site Admin
User avatar
You need another loop meaning "while the user is cheating".

Code:
//some introduction

def cheating = true
while(cheating) {
  starttime=getTime();

  while(starttime+time>getTime())
  {
  //Line writing
  }
 
  //Cheat check
  cheat = time / timelimit
  cheating = counter < cheat / 2
  if (cheating){ show("You are cheating"); } else {openCdTrays()}
}


Top
 Profile Send private message 
 
 Re: getString with a timeout. Is it possible?
PostPosted: Thu Jul 14, 2016 1:17 pm 
Offline
Active member
Thank you, doti!


Top
 Profile Send private message 
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 15 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  


Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Maroon Fusion theme created by Oxydo
Software, theme modifications, phpBB modification by Doti 2010 - 2020
This website uses session cookies only.