Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

sort list

cecino Cicerone
Registered User
Join date: 3 Feb 2007
Posts: 4
08-25-2007 02:53
hi
i have a problem to sort a list,
i would like to sort the list for the best time on top, the message wich contain the avatar name and the time lokks exact like this cecino Cicerone 03:02,
i read all the wikis and search the forum, i try 4 days too got this, but maybe my english is to bad or i have something wrong in my had and getting stupid on this, i try llList2integer and some sort funktions but it not work, thanks for a tip!!!!! or a code sniped
here is the script, its not so nice at this stadium:

list racer;
vector v_textcolor = <1,1,1>;
default
{
state_entry()
{
llListen(6041,"","","";);

}
touch_start(integer total_number)

{

llSay(0, "AvaRacer List:" );
integer len = llGetListLength( racer );
integer i;
for( i = 0; i < len; i++ )
{
llSay(0, llList2String(racer, i) );
}
llSay(0, "Total = " + (string)len );
}



listen(integer channel,string name, key id, string message)
{
if(message=="passta";)
{
state on;
}
}
}
state on
{
state_entry()
{
llListen(5002,"","","";);
}
listen(integer channel,string name,key id,string message)
{
if(message!="00:00";)
{

llSetText((string)(message),v_textcolor,TRUE);
racer+=message;
state default;
}
}
Qie Niangao
Coin-operated
Join date: 24 May 2006
Posts: 7,138
08-25-2007 06:12
Well, the racers need to learn their "strides" ;)

Something like this, maybe:

CODE
list stridedRacer =
[ "03:02", "cecino Cicerone"
, "04:03", "Qie Niangao"
, "01:00", "Philip Linden"
] ;



default
{
state_entry()
{
llListen(1, "", NULL_KEY, "");
llOwnerSay("Say '/1 Racer Name | 99:99' to enter a new time. Touch to dump sorted list of racers.");
}
touch_start(integer total_number)
{
stridedRacer = llListSort(stridedRacer, 2, TRUE);
integer racerIdx = 0;
integer racerLength = llGetListLength(stridedRacer);
while (racerIdx < racerLength)
{
llSay(0, llList2String(stridedRacer, racerIdx+1) + " " + llList2String(stridedRacer, racerIdx));
racerIdx += 2;
}
}

listen(integer channel,string name, key id, string message)
{
list inputRecord = llParseString2List(message, ["|"], []);
stridedRacer = (stridedRacer = []) + stridedRacer // old hack to limit heap fragmentation
+ llStringTrim(llList2String(inputRecord, 1), STRING_TRIM)
+ llStringTrim(llList2String(inputRecord, 0), STRING_TRIM);
}
}
cecino Cicerone
Registered User
Join date: 3 Feb 2007
Posts: 4
yes it works!!
08-25-2007 11:31
thanks!! alot it works very good.