SexScripts : Random images (SOLVED) - UPDATE - https://ss.deviatenow.com:443/viewtopic.php?f=4&t=638 Page 1 of 1

Random images (SOLVED) - UPDATE

cd228 [ Wed Aug 31, 2016 3:16 pm ]

For those who would like to get a more clean function here it is:

Code:
def setRandomImage = { folderName, imagePrefix ->
   def folder = new File(System.getProperty("user.dir")+"/images/(Your project name)/"+folderName+"/")
   def fileArray = folder.listFiles()
   def numberOfImages = 0

   for (def i= 0; i < fileArray.length;i++){
      if(fileArray[i].toString().contains(imagePrefix)) numberOfImages++
   }   
   setImage("(Your project name)/"+folderName+"/"+imagePrefix+(getRandom(numberOfImages)+1)+".jpg")
}


To call it simply write:
Code:
setRandomImage("(The folder in your project the images are in)", "(The prefix of the images)")


If you want to find any image in a given folder use this function:

Code:
def setCompletelyRandomImage = { folderName ->
   def folder = new File(System.getProperty("user.dir")+"/images/(Your project name)/"+folderName+"/")
   def fileArray = folder.listFiles()
   setImage(fileArray[getRandom(fileArray.length)].toString())
}


And to call it:
Code:
setCompletelyRandomImage("(Folder from which you want a random image)")



________________________________________


Hello

A similar question has been asked before, but I was curious to know if there is a way to display random images from a folder without knowing how many images are in there. like setImage("folder/image*.jpg") where there might be 2 or 6 images in the folder.

Re: Random images

cd228 [ Wed Aug 31, 2016 4:19 pm ]

Solved it!:D

For others who wants to do the same, this is how I did it.

Code:
def setImageAI ={ name, pic -> //Takes name (of mistress) and pic (the type of prefix)
def folder = new File(System.getProperty("user.dir")+"/images/(YOUR PROJECT NAME)/"+name+"/")
def fileArray = folder.listFiles()
   
def numberOfImages = 0
for (def i= 0; i < fileArray.length;i++){ //Sorts through all the files in the folder
   if(fileArray[i].toString().contains(pic)) numberOfImages++ //if there are files with the prefix in it increase the number
   }   
setImage("(YOUR PRJECT NAME)/"+name+"/"+pic+(getRandom(numberOfImages)+1)+".jpg")
}


and to initiate the function:
Code:
setImageAI("Michaela", "breasts")


This will basically take a folder named Michaela, sort through all the files, and every time it encounters a file which contains the name "breasts", it will increase the variable called numberOfImages.
After that you can simply setImage to a random one containing that prefix.

I just have a folder called Michaela, and the several files called breasts1, breasts2, ass1, ass2, ass3, etc.
No matter how many files you have of one type, the function still chooses a random image from those with that prefix.

Re: Random images (SOLVED)

arthurb [ Wed Aug 31, 2016 8:22 pm ]

Cool 8-)

Thanks!

Re: Random images (SOLVED)

cd228 [ Fri Sep 02, 2016 12:33 pm ]

arthurb wrote:
Cool 8-)

Thanks!

No problems.
I think it can be a useful feature in other projects, as you do not always know how many pictures are in a future expansion.
My project farkel was kind of limited by the fact that I needed to match all images of different models. Now I can just add images without worrying about the number:)

Re: Random images (SOLVED)

Banjo [ Sun Sep 04, 2016 2:56 pm ]

Well done, mate! I wanted to do this myself several times and had asked before, but nobody else seemed to be able to figure it out and it was marked as "not possible" (i.e. you needed to know how many images). Having a workaround for this is awesome, thanks for sharing!

Re: Random images (SOLVED) - UPDATE

cd228 [ Tue Sep 06, 2016 1:06 pm ]

Check first post for update

Re: Random images (SOLVED) - UPDATE

doti [ Tue Sep 06, 2016 3:07 pm ]

This is good and should work.
I think the name of the pictures must be :
Code:
prefix1.jpg
prefix2.jpg
prefix3.jpg
...


So the name starts with 1, no 0 (like 01, 02...), ends with ".jpg" and not ".jpeg"

Re: Random images (SOLVED) - UPDATE

cd228 [ Wed Sep 07, 2016 6:28 pm ]

doti wrote:
This is good and should work.
I think the name of the pictures must be :
[code]
prefix1.jpg
prefix2.jpg
prefix3.jpg
...
[code]

So the name starts with 1, no 0 (like 01, 02...), ends with ".jpg" and not ".jpeg"



Precisely. Except in the second function, where it will pic any random jpg in the folder

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