Corresponding and Interchanging Lists
|
Douglas Callahan
Fresh Prince Of SL
Join date: 2 Jul 2004
Posts: 349
|
03-29-2005 16:53
I have a list that keeps av names and corresponding scores for these avs. However, since list length maximum is in the 70s, this will only allow 30-40 people to play. How can I make a second/third/fourth list that will continue the scores from list 1. These lists would need to be able to change information, ie:
Player1 has score of 3 and is the last on list 1. Player2 has score of 2 and is the first on list 2. Then Player2 gets two points and now has a score of 4. This would mean that Player2 would have to take Player1s place and vice versa. How could I do this?
|
Rayve Mendicant
Scripts for L$5 billion
Join date: 12 Mar 2005
Posts: 90
|
03-29-2005 18:39
Sup Doug, This is one way to do it...unless I misunderstand  each list can only contain about 72 items; however, you can add these lists to combine them into 1. Once you are done sorting the list though, i believe you would have to split it again. Not really a big deal though. list group1; // make these strided list in form [score1,player1,score2,player2.... list group2; list group3; list group4; list temp; ... list temp = group1 + group2 + group3 + group4; ... //update scores code ... llSortList(temp,2,FALSE); sorts the strided list in descending order (high score to low score) group1 = llList2List(temp,0,49); group2 = llList2List(temp,50,99); group3 = llList2List(temp,100,149); group4 = llList2List(temp,150,199); Hope this helps. cya in-game.
|
Water Rogers
Registered User
Join date: 1 May 2003
Posts: 286
|
03-30-2005 03:05
From: Rayve Mendicant ...each list can only contain about 72 items... This is not completely accurate. A list can contain as many items as there is script memory to hold it which depends upon what datatypes are in the list. So eventually, with your solution, you can still run out of memory (stack-heap collision). One way of going about it (if you are storing large amounts of data in a list), is to have a single script for each list, thus maximizing the amount of memory each can hold. If you design your scripts to accept and send link messages, then you can check against the A)physical memory of the script or B)cap of how many items per list you would like to hold via the main script. This is also helpful because you can recompile the master script as many times as you need to without physically affecting the other "list scripts" (and thus not having to erase data in the scripts each time you have to recompile). You can also add more "list scripts" as you need in the future by running business logic on how many scripts the object contains etc. *Note that this solution does not guarantee data retaining. Scripts at any time are subject to losing the data that they hold for whatever reason. Your safest bet to store data is to delve into emailing and/or RPC-XML.* --Water
_____________________
From: Philip Linden For the more technically minded - the problem is actually NOT the asset server (or 'asshat' as you prefer to affectionately call it herein).
|
Jeffrey Gomez
Cubed™
Join date: 11 Jun 2004
Posts: 3,522
|
03-30-2005 07:35
To clarify, the 72 max for lists is only enforced in the compile phase of the script - that is, if you were to add 72 values by hand in a global list, it would throw an error. As for scripting, the max is (as already mentioned) the memory of the script buffer. You can go beyond that by running several scripts in tandem but... well, try something simpler, shall we? Your best bet is actually to store data in client scripts, which are retained in inventory (obviously the script would need measures to prevent tampering). These could call their values against a "leaderboard" script. Water is correct in that lists can "for whatever reason lose their data" - and, most commonly, this is the result of a sim restarting. However, if the script is kept in inventory, I believe the carbon copy is saved against whatever asset server your avatar uses, offering better data protection. PS: Animation Factory is the devil, Water.
_____________________
---
|
Water Rogers
Registered User
Join date: 1 May 2003
Posts: 286
|
03-31-2005 09:01
<Off-Topic> THAT'S where I got that 2 years ago when i joined! I was wondering for the longest time... Perhaps time to change the 'ol forum av. Thanks, JG  --Water
_____________________
From: Philip Linden For the more technically minded - the problem is actually NOT the asset server (or 'asshat' as you prefer to affectionately call it herein).
|
Graham Mondrian
Registered User
Join date: 16 Mar 2005
Posts: 59
|
03-31-2005 13:56
How fast do you need to change them? You could use a notecard as a database but thats gonna be slow at reading the lines in, as long as you know exactly which lines to change, you might be ok. The problem would be when you change the player1 slot and have to rewrite hundreds of lines which could take into the 10s of seconds.
|
Douglas Callahan
Fresh Prince Of SL
Join date: 2 Jul 2004
Posts: 349
|
Memory
03-31-2005 17:38
ok i understand that if you add to lists by += [entry], it is unlimited until you run out of memory, but exactly how many entries is this? I don't want to have to make client scripts if I do not need too, and if I do, I don't want to make too many.
|
Talena Wallaby
Registered User
Join date: 20 Mar 2005
Posts: 19
|
03-31-2005 17:44
From: Douglas Callahan ok i understand that if you add to lists by += [entry], it is unlimited until you run out of memory, but exactly how many entries is this? I don't want to have to make client scripts if I do not need too, and if I do, I don't want to make too many. Try it out and find out. It depends on a lot of factors, what else is going on that is taking up memory in the script. If you're storing one character in each element in the string you'll have more elements before you run out of memory than if you store 15 characters in each element in the string.
|