SexScripts : Ordering values in show message - https://ss.deviatenow.com:443/viewtopic.php?f=4&t=700 Page 1 of 1

Ordering values in show message

markdomx [ Wed Jul 12, 2017 1:20 pm ]

In one of my script I have tre girls involved in a match.
At the end of it they obtain 3 different scores.
Is it possible to show the result in a particoular order?

I know how to show the values:

set a=5
set b=3
set c=10
show("Girl one has:"+a+"points\n\nGirls two has:+b+"points\n\nGirls three has:"+c+"points")


...but can I show in the order from the winner to the looser (c b a)?
Thank you and sorry for my english

Re: Ordering values in show message

markdomx [ Wed Jul 12, 2017 2:08 pm ]

Partial solution:

def girl1 = " Becky"
def girl2 = " Jony"
def girl3 = " Liz"
def points1=5
def points2=9
def points3=6

def a=points1+girl1
def b=points2+girl2
def c=points3+girl3


def order = numList.sort()
show("Results:"+order+"...")
showButton("ok")


In this case I obtain alphabetical order: 5 Becky, 6 Liz, 9 Jony

Re: Ordering values in show message

markdomx [ Wed Jul 12, 2017 2:16 pm ]

SOLVED (I'm not mad to write alone: if i can help someone...)

def girl1 = " Becky"
def girl2 = " Jony"
def girl3 = " Liz"
def points1=5
def points2=9
def points3=6

def a=points1+girl1
def b=points2+girl2
def c=points3+girl3

def order = numList.sort()

def first = numList[2]
def second = numList[1]
def last = numList[0]

show("First: "+first+"\n\nSecond: "+second+"\n\nThird: "+last+"\n\n...")
showButton("ok")

Re: Ordering values in show message

doti [ Wed Jul 12, 2017 3:00 pm ]

Your solution is good (the creation of numList is missing ?)
Here is an advanced clean solution using "maps" :
Code:
// keys are the names, values are the resp. points
def m = ["Becky":5, " Jony":9, " Liz":6]
// sort by inverse value
m = m.sort { -it.value }
def names = m.keySet() as List
show("First : "+names[0]+" : "+m[names[0]] + ", "+
    "Second : "+names[1]+" : "+m[names[1]] + ", "+
    "Third : "+names[2]+" : "+m[names[2]] + ".")

Shows :
Code:
First :  Jony : 9, Second :  Liz : 6, Third : Becky : 5.

Re: Ordering values in show message

markdomx [ Wed Jul 12, 2017 4:33 pm ]

TY doti, now I start to study maps...
In my scripts point are variables:

// keys are the names, values are the resp. points
def m = ["Becky":Becky, "Jony":jony, "Cindy":cindy, "Lulu":Lulu, "Valeria":errori]
m = m.sort { it.value }
def names = m.keySet()
show(m)
showButton("ok")

produces: {Becky=0, Lulu=0, ...... } -------CORRECT


BUT


show(m.names[0]) --> java.lang.NullPointerException: Cannot invoke method getAt() on null object(@ line 85)

show(names[0])--> groovy.lang.MissingMethodException: No signature of method: java.util.LinkedHashMap$LinkedKeySet.getAt() is applicable for argument types: (java.lang.Integer) values: [0]
Possible solutions: getAt(java.lang.String), getAt(java.lang.String), putAt(java.lang.String, java.lang.Object), wait(), last(), sort()(@ line 85)

Re: Ordering values in show message

doti [ Wed Jul 12, 2017 6:00 pm ]

Sorry, there was an update, I had to add as List in the code above.

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