SexScripts : Helper Functions - https://ss.deviatenow.com:443/viewtopic.php?f=4&t=661 Page 1 of 1

Helper Functions

modnar [ Wed Nov 23, 2016 4:38 pm ]

I've been thinking of a few functions, as I write them and find them useful I will post/update to help others.

The first one is a "real wait time" - If your script is making somebody do a task, and you require them to do the full amount of time set, then this function will help you. It can be adjusted to carry out the full amount of time depending on the speed set, or you could adjust it to administer a punishment also! There is 2 ways to setup the calculation of the additional time to wait, I'll leave that choice up to you.


Code below:

function: realWait(time) (Time in seconds)
Show spoiler



function: roundUpNumberByUsingMultipleValue(double number, int multiple);
Show spoiler



Please let me know your thoughts, useful or not useful.

Thanks!

* Edit, forgot to attach a sample output of running this at Speed = Faster *
* Could possibly run a loop and find mean/mode/average if somebody wants :P *

Show spoiler

External Language Files

modnar [ Tue Feb 21, 2017 1:46 pm ]

Hi all,

I was working on an example of how to keep one script but with multiple language files. I thought it may help anybody looking to support this. Maybe it is ready for you to use straight out the box, maybe you would like to extend. Please let me know your thoughts!

You would need to create your own language selection at startup but the below should give you a general idea.

You will need to replace "script_name" with a naming method of your own


The language file. I decided to name the EN version "en_GB.lang" and placed it within a sub-directory under "scripts"
Show spoiler



The second part is to use this in your script. I have placed some various checks in place.


Show spoiler



So now you have loaded the language file, how to use it going forward within the script. This part will show information regarding android
Show spoiler

Motion Detection

modnar [ Thu Mar 09, 2017 10:21 pm ]

Hi all,

Might be useful to somebody... Though this is only tested on windows! Also if your script crashes the web cam lock may still be present and require you to kill the exe process to unlock the camera. Would love to see this added as a permanent feature! If there was a shutdown / unload function called that would be amazing. You could also try wrapping it in a try {} block and finally close the webcam... Like I say this is experimental as I just wanted to test some things. It's up to you what you do to count how many times etc, this just show's it working. Oh it also puts a live webcam feed where the image would usually appear.


You can call the detectMotion by using this:

Code:
- secondsCapture: How long to run for?
- areaThreshold: /* Set percentage fraction of detected motion area threshold above which it is classified as "moved". Minimum value for this is 0 and maximum is 100, which corresponds to full image covered by spontaneous motion. */
- pixelThreshold: /* Set pixel intensity difference threshold above which pixel is classified as "moved". Minimum value is 0 and maximum is 255. Default value is 10. This value is equal for all RGB components difference. */
- inertia: /*  How long motion is valid (in milliseconds). (Think min is 100ms) */
- interval: /* Motion check interval in milliseconds. After motion is detected, it's valid for time which is equal to value of 2 * interval. */


Code:
detectMotion(10, 5, 2, 100, 100); /* secondsCapture, areaThreshold, pixelThreshold, inertia, interval */


Show spoiler

Live webcam viewer

modnar [ Thu Mar 09, 2017 10:26 pm ]

Another webcam helper - This may help people who wish to make sure the webcam is in the correct position before starting / taking images. Again windows tested only, and problems apply as above.

Use the following which will allow them to view for 10 seconds, and again 10 seconds if they require.
Code:
while (true)
{
  if (getSelectedValue("Do you wish to preview the webcam for 10 seconds?", [ "No" , "Yes" ]) == 0)
  {
    break;
  }
  showWebcamView(10);
}


Passing through a positive number greater than or equal to 1 will show the feed for that many seconds.
Passing through the number 0 "showWebcamView(0);" will show a button, but the webcam feed will only update every second. Once the button is pushed the feed is stopped. A second seems to be enough to be able to click, and see what's happening.

Show spoiler

Re: Helper Functions

modnar [ Thu Mar 09, 2017 10:27 pm ]

Please, let me know if you find these of interest. I'd love to know if you are thinking of using any of my functions or part of them in the future. It's good to know the time I put into this is helpful to others.

Re: Helper Functions

doti [ Sat Mar 11, 2017 10:26 am ]

Thank you
Writers will encounter thoses functions with the search engines during the next months/years, so it will be useful anyway.

Re: Helper Functions

martlb [ Sat Mar 11, 2017 7:20 pm ]

Whoa!
The webcam functions are really impressive!
I never could create something like this or even think this is possible!
Thank you for that!

Just copy paste and tested it and it works immediately, well done!

Only wondering the areaThreshold and pixelThreshold will be user/webcam dependent, doesn't it?
When used in a script, this has to be sort out first for each user, isn't it?
Please correct me if I'm wrong.
Is there away to display these values, like it's done in: http://cornertime.herokuapp.com/
Could also be done displaying the mean value in text afterwards, for example after a test corner time run for one minute.
The script can then send the user for a test corner time run, see what's value's are reasonable, let them enter once...

I remember, I once started a corner time using this site with a threshold of 1%, thinking, if I move, I deserve to be punished.
But a threshold of 1% was really impossible in my case, even when standing absolutely still.
I think this values will be dependent of the area, the webcam used... I don't know...

Already looking forward for creating a mean corner time script .... :twisted:
Or checking if your cock doesn't twitch ...
Or checking if you keep dancing as told ...

Re: Helper Functions

builder-builder [ Mon Mar 13, 2017 8:51 pm ]

Your motion detection code rocks. Great work!

I'm writing a script and for the moment I write the calibration process. Will show it to you soon.

What I can already do after user stands still 10 secs & moves 10 secs
- Increase sensitivity
- Decrease sensitivity
- See how long user moved/didn't move, thanks to false positives
- See if anyone is in the picture

For my mean little script there is one thing I need to prevent the user from manipulating the test by moving the camera. I need a script for picture comparison. Idea, user starts calibration script, 1st shot is taken, user ends script, second shot is taken, then comparison between the two pic. If both pictures match by x percent, everything is fine, else cheating was detected.

Ideas how to do it?

Re: Helper Functions

cd228 [ Thu Feb 15, 2018 7:57 pm ]

I was looking for a method I have used before, but long forgotten.
I cannot remember if I have posted it somewhere before, but just in case I haven't I will post it here.

Basically it works as a multiple choice quiz, where you want the answers to be scrambled, so they are never in the same position if the player choose to play again:


Code:
def shuffleList = { array, noOfElements ->                //This function shuffles an array that is sent to it.
   for (int i=0; i<noOfElements; i++){
      int s = i+(int)(getRandom(noOfElements-i))
      def temp = array[s]
      array[s] = array[i]
      array[i] = temp
   }

}

def arrayAnswers = []                           //Sets up an empty array we need to contain the answers

//The code below is used for the quiz itself:
answerArray = ["Blue","Hazel","Brown","Green","Grey"]     //Fills the arrays with potential answers
shuffleList(answerArray, answerArray.size)                        //Shuffles the array
if(answerArray[getSelectedValue("What eye color did the girl have?",answerArray)]=="Brown")   //The getSelectedValue returns an integer and the answerArray[integer] corresponds to the string the player has chosen.




Re: Helper Functions

doti [ Fri Feb 16, 2018 7:58 pm ]

Very good code, thank you. But : Collections.shuffle(... list ...) does the same thing. :oops:

Re: Helper Functions

cd228 [ Sun Feb 18, 2018 2:48 pm ]

Cool I didn't know.
So how would the code look with the collections.shuffle?

Re: Helper Functions

doti [ Sun Feb 18, 2018 3:08 pm ]

It looks quite identical
Code:
def answerArray = []                           //Sets up an empty array we need to contain the answers

//The code below is used for the quiz itself:
answerArray = ["Blue","Hazel","Brown","Green","Grey"]     //Fills the arrays with potential answers
Collections.shuffle(answerArray)                        //Shuffles the array
if(answerArray[getSelectedValue("What eye color did the girl have?",answerArray)]=="Brown")   //The getSelectedValue returns an integer and the answerArray[integer] corresponds to the string the player has chosen.

Re: Helper Functions

cd228 [ Sun Feb 18, 2018 4:52 pm ]

Great:).
Do you have a list of the different functions that works with collections?

Re: Helper Functions

doti [ Sun Feb 18, 2018 6:17 pm ]

It's from Java so here, but I don't find al lot of interesting things.
  • Collections.frequency( list, objet ) Returns the number of elements in the specified collection equal to the specified object.
  • Collections.min( list ) and Collections.max( list )
  • Collections.reverse ( list ) returns the reversed list

Page 1 of 1 All times are UTC + 1 hour [ DST ]
https://ss.deviatenow.com:443/
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Maroon Fusion theme created by Oxydo
Software, theme modifications, phpBB modification by Doti 2010, 2011