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
 Can I simplify this small section of my selfbondage script?
PostPosted: Sat Oct 19, 2019 1:04 am 
Offline
Regular
Hi,

I'm writing a long self bondage script with tasks, games and challenges you need to pass to be released. One section is asking questions about images that are selected at random from a list.

This is the start of the code I have to check if the Answer given by the user matches the correct answer.

question = getRandom(300)

if(question == 0){ Q=Q0
QArray=Q0Array
A=A0 }

if(question == 2){ Q=Q2
QArray=Q2Array
A=A2 }

if(question == 3){ Q=Q3
QArray=Q3Array
A=A3 }
........... and so on...

slaveChoice = getSelectedValue(""+Q+"):", QArray)
slaveChosen = QArray[slaveChoice]
if (slaveChosen == A) {correct = correct +1} else {wrong = wrong +1}

where Q is the question, QArray is the list of possible answer to choose from and A is the correct answer

My question is this,

is there a way I can directly add the random number assigned to "question" into only ONE "if" section and I do not need to write 300? I have tried every idea I can think of and still no luck.

i.e. Q = Q"+question+"; but this doesn't work and I cant think of a solution.


Thanks
Taylor


Top
 Profile Send private message 
 
 Re: Can I simplify this small section of my selfbondage scri
PostPosted: Tue Oct 22, 2019 5:56 pm 
Offline
Site Admin
User avatar
Your data can be in only one complex array variable like this :
Code:
def data = [
["Q":"...", "QArray":["...","...","..."], "A":"..."],
["Q":"...", "QArray":["...","...","..."], "A":"..."],
["Q":"...", "QArray":["...","...","..."], "A":"..."],
...
]


Then reading this array is simple :
Code:
def question = getRandom(data.size())
def Q=data[question]["Q"]
def QArray=data[question]["QArray"]
def A=data[question]["A"]


Top
 Profile Send private message 
 
 Re: Can I simplify this small section of my selfbondage scri
PostPosted: Thu Oct 24, 2019 11:55 am 
Offline
Regular
Thanks Doti, I’ll give it a try when I have some spare time and see if I can get it to work. I’ve done little to no real programming prior to this so I’m just learning by copying other people’s scrips I like.

Cheers


Top
 Profile Send private message 
 
 Re: Can I simplify this small section of my selfbondage scri
PostPosted: Thu Nov 07, 2019 10:40 pm 
Offline
Regular
Hi Doti, Unfortunately I'm unable to get the code you suggested to work.

This is what I have tried,

def slaveChoice = null
def slaveChosen = null
def question = null
def Image = null
def correct = 0
def wrong = 0

def Q = null
def QArray = null
def A = null

def data = [
["Q":"What is the year of the copyright of the image", "QArray":["2007", "2008", "2009", "2010", "2011"], "A":"2009", "Image":"1"],
["Q":"How many rings was the girl wearing?", "QArray":["1", "2", "3", "4", "5"], "A":"2", "Image":"2"],
["Q":"What is the correct one?", "QArray":["A", "B", "C"], "A":"B", "Image":"3"],
["Q":"How many tatoos does the girl have?", "QArray":["0", "1", "2","3", "4"], "A":"2", "Image":"4"],
["Q":"How many piercings does the girl have?", "QArray":["0", "1", "2","3", "4"], "A":"3", "Image":"5"],
["Q":"What color was the ballgag she's wearing?", "QArray":["Red", "Blue", "Green","Black", "White"], "A":"Green", "Image":"6"],
["Q":"What is the correct one?", "QArray":["A", "B", "C"], "A":"C", "Image":"7"],
["Q":"How many chothespins are punishing her breasts?", "QArray":["5", "6", "7", "8", "9"], "A":"7", "Image":"8"],
["Q":"What was written on the paper that she's holding?", "QArray":["121", "212", "222", "112", "211"], "A":"212", "Image":"9"],
["Q":"Wich one is correct?", "QArray":["A", "B", "C"], "A":"B", "Image":"10"],
]


//set data

question = getRandom(data.length)
Q=data[question]["Q"]
QArray=data[question]["QArray"]
A=data[question]["A"]
Image=data[question]["Image"]



// an image is then shown for a few seconds on screen and then the question is asked.

slaveChoice = getSelectedValue(""+Q+"", QArray)
slaveChosen = QArray[slaveChoice]

if (slaveChosen == A) {correct = correct +1} else {wrong = wrong +1}

The error I get is refereed to question = getRandom(data.length) statement and is:

Error in simulation (maybe not a real error) groovy.lang.MissingMethodException: No signature of method: ss.FullScript_teaseortorture_HaileysTeaseorTortureCopy.getRandom() is applicable for argument types: (ArrayList) values: [[null, null, null, null, null, null, null, null, null, null]]
Possible solutions: getRandom(double), getRandom(java.lang.Integer)(@ line 329)

Do you have any ideas?

Thanks
Taylor


Top
 Profile Send private message 
 
 Re: Can I simplify this small section of my selfbondage scri
PostPosted: Fri Nov 08, 2019 4:47 pm 
Offline
Site Admin
User avatar
Sorry, corrected the code above


Top
 Profile Send private message 
 
 Re: Can I simplify this small section of my selfbondage scri
PostPosted: Sat Nov 09, 2019 8:50 pm 
Offline
Regular
doti wrote:
Sorry, corrected the code above


Got it all working now, Thank you Doti.

So much better than having 300 if statements :roll: .

Cheers
Taylor


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:  


cron
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.