Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Looking for Help / Feedback

Knight Nootan
Registered User
Join date: 26 May 2008
Posts: 73
06-22-2009 15:05
Not sure if I am even going about this the right way. I have an object that when used creates a score, I would like to have it go to a leader board. I had a thought that I could use llListen in the board and when the object is used it would chat to the board the name and desc, the desc being the score. If the new score is higher than any of the ones already listed it would post the new name and show it via hoovering text.

My issue is understanding how to get the leader board to recognize the new score and change the leader board as needed. I was also thinking maybe llSensor or llSensorRepeat might work for this but after reading up on it I am not so sure it would.

Thank you to anyone who might be able to help shed some light on this for me.
Rezz Mode
Registered User
Join date: 14 Jun 2009
Posts: 4
Re:
06-22-2009 15:24
Hi Knight. Ok, what i think you should do is have the object send a message on a certain channel to the leader board. The leader board should always be listening on that channel and should store the score and the UUID of the user who got it. Then it will check if the score is in the top three, and if it is it posts it. Its really simple, Just have the leader board listening and the object llRegionSay() on a negative channel the UUID and score.
I hope i have understood you correctly and this helps... IM me inworld if not.
Knight Nootan
Registered User
Join date: 26 May 2008
Posts: 73
06-22-2009 16:05
thats exactly what I am trying to do but I cant. Just not sure how to have the leader board store the scores and then be able to replace it when needed. I have been playing around with it and reading as much as possible but just cant get it to work.
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
06-22-2009 19:51
From: Knight Nootan
thats exactly what I am trying to do but I cant. Just not sure how to have the leader board store the scores and then be able to replace it when needed. I have been playing around with it and reading as much as possible but just cant get it to work.

Have the scripts chat the score and the owner key to the game board. Store this info in a list in strides. When a uuid and a score comes in use llListReplaceList to replace that score. To find out the high score to update just use llListSort which can sort in strides(Sort by the score):

http://lslwiki.net/lslwiki/wakka.php?wakka=list

http://lslwiki.net/lslwiki/wakka.php?wakka=llListSort

http://lslwiki.net/lslwiki/wakka.php?wakka=llListReplaceList
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
06-22-2009 23:05
a simplifed example of using sorting to fill the list, no filtering, and it's on an open public listen so you can just chat a number to test it (don't keep the public channel it's just to demo it)
CODE

list gLstTop;
integer gIntMax = 3; //-- top 3 scores

default{
state_entry(){
llListen( 0, "", "", "" );
}

listen( integer vInt, string vStr, key vKeySpeaker, string vStrScore ){
gLstTop += [(integer)vStrScore , llKey2Name( llGetOwnerKey( vKeySpeaker ) )];
gLstTop = llListSort( gLstTop, 2, FALSE );
gLstTop = llList2List( gLstTop, 0, (2 * gIntMax - 1) );
}
}

the same example with pre calculated max and variable insertion
CODE

list gLstTop;

default{
state_entry(){
llListen( 0, "", "", "" );
}

listen( integer vInt, string vStr, key vKeySpeaker, string vStrScore ){
gLstTop = llList2List( llListSort( gLstTop + [(integer)vStrScore, llKey2Name( llGetOwnerKey( vKeySpeaker ) )], 2, FALSE ), 0, 5 );
}
}
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Knight Nootan
Registered User
Join date: 26 May 2008
Posts: 73
06-23-2009 15:06
ok, I see what you are doing to get the list and store it, so what I would have to do is use the llList2String feature to get the list and be able to display it via hoovering text or however I need?
Knight Nootan
Registered User
Join date: 26 May 2008
Posts: 73
06-23-2009 15:39
Void,

Using your first example of:

Code:



list gLstTop;

integer gIntMax = 3; //-- top 3 scores



default{

state_entry(){

llListen( 0, "", "", "" );

}



listen( integer vInt, string vStr, key vKeySpeaker, string vStrScore ){

gLstTop += [(integer)vStrScore , llKey2Name( llGetOwnerKey( vKeySpeaker ) )];

gLstTop = llListSort( gLstTop, 2, FALSE );

gLstTop = llList2List( gLstTop, 0, (2 * gIntMax - 1) );

}

}


how would I get it to display the objects name the score came from versus the score itself? Or if I needed to show both the objects name and the score? I am still trying to learn as much as possible on this issue. Thnaks!
Knight Nootan
Registered User
Join date: 26 May 2008
Posts: 73
06-23-2009 18:19
OK, I have gotten it to display the list via hoovering text. But it seems to want too not show all top three and in the correct order. Not sure why that is. What it does is show the top 2, then when a 3rd one is done with a higher score it just removes the top one and now they are out of order. Is there a way to correct this?
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
06-23-2009 19:30
I would guess it's the method you are using to dump the list....

at a guess you are looping through the list 2 items at a time... but you are starting 1 index off and running from either-1 to 1 or 1 to negative one when what you want is 0 to 2 or the reverse.

you can test that it's right by using (string)gLstTop, or llDumpList2String( gLstTop, " " );

you can change the order they are placed into the list if that works better for you, and change the ides for sorting from 0 to 1

to get the name of the object, instead of using llKey2Name( llGetOwnerKey( vKeySpeaker) )just use the vStr (which you can change to something more helpful to the person reading the script)
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
06-23-2009 22:13
helped online, the problem proved trickier than it should have been at first glance, but here's an updated version that switches between scores and names on a timer...

CODE

list gLstTop ;
integer gBooNames;
list gLstPlace = ["1st", "2nd", "3rd", "4th", "5th"];

uUpdateText(){
string vStrTxt;
list vLstTop = llList2ListStrided( llList2List( gLstTop, (gBooNames = !gBooNames), -1 ), 0, -1, 2 );
integer vIntCnt = (vLstTop != []);
while(vIntCnt--){
vStrTxt = "\n" + llList2String( gLstPlace, vIntCnt ) + ": " + llList2String( vLstTop, vIntCnt ) + vStrTxt;
}
llSetText( vStrTxt, < 1.0, 1.0, 0.0 >, 1.0 );
llSetTimerEvent( 15.0 );
}

default{
state_entry(){
llListen( 0, "", "", "" );
llSetText( "", ZERO_VECTOR, 0.0 );
}

listen( integer vInt, string vStr, key vKeySpeaker, string vStrScore ){
gLstTop = llList2List( llListSort( gLstTop + [(integer)vStrScore, llKey2Name( llGetOwnerKey( vKeySpeaker ) )], 2, FALSE ), 0, (2 * (gLstPlace != []) - 1));
uUpdateText();
}

timer(){
uUpdateText();
}
}
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Knight Nootan
Registered User
Join date: 26 May 2008
Posts: 73
06-30-2009 14:31
Just wanted to say Thank You to Void for taking the time to help me figure this out!!!!!!!!!