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
 Ordering values in show message
PostPosted: Wed Jul 12, 2017 1:20 pm 
Offline
Active member
User avatar
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


Top
 Profile Send private message 
 
 Re: Ordering values in show message
PostPosted: Wed Jul 12, 2017 2:08 pm 
Offline
Active member
User avatar
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


Top
 Profile Send private message 
 
 Re: Ordering values in show message
PostPosted: Wed Jul 12, 2017 2:16 pm 
Offline
Active member
User avatar
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")


Top
 Profile Send private message 
 
 Re: Ordering values in show message
PostPosted: Wed Jul 12, 2017 3:00 pm 
Offline
Site Admin
User avatar
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.


Top
 Profile Send private message 
 
 Re: Ordering values in show message
PostPosted: Wed Jul 12, 2017 4:33 pm 
Offline
Active member
User avatar
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)


Top
 Profile Send private message 
 
 Re: Ordering values in show message
PostPosted: Wed Jul 12, 2017 6:00 pm 
Offline
Site Admin
User avatar
Sorry, there was an update, I had to add as List in the code above.


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: Yandex [Bot] and 6 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.