Seagel Neville
Far East User
Join date: 2 Jan 2005
Posts: 1,476
|
08-12-2005 08:07
Hello there, If someone touches the object, his id would be brought in the list, gGiven. And someone who has already been in the list touches it again, he is dropped out from the list. Then a new person touch it, his id would be added in the list. But I want the new id to insert the place where someone dropped out. See my script. key detKey; list gGiven; list temp;
default { touch_start(integer totalNum) { detKey = llDetectedKey(0); temp += detKey; // To know whether detKey has already been stored in gGiven list, // Store it in temp list temporally, and compare them. if (llListFindList(gGiven, temp) == -1) { gGiven += detKey; // detKey is stored in gGiven list. temp = []; // temp list is cleard. } else { gGiven = llDeleteSubList(gGiven, (integer)llListFindList(gGiven, temp), // If the id has already been in the list, it would be dropped out. temp = []; // temp list is cleard. } } } This script would do that: gGiven [A, B, C, D] If B touched it, he would be dropped out and it would be that gGiven [A, C, D]. And if new E person touch it, it would be that gGiven [A, C, D, E]. But I want it to be that gGiven [A, E, C, D]. Can I do this?
_____________________
 Seagel Neville 
|
Jesrad Seraph
Nonsense
Join date: 11 Dec 2004
Posts: 1,463
|
08-12-2005 08:12
Lists don't keep track of what information got deleted recently, so no, there is no simple way for you to do this.
Now, you can keep track of elements deleted yourself in a seperate list: Whenever an element is "dropped out" of the list copy it over into another list along with its previous emplacement. When another gets added to the main list use the info to place it at the correct place and the remove that used info from the second list.
_____________________
Either Man can enjoy universal freedom, or Man cannot. If it is possible then everyone can act freely if they don't stop anyone else from doing same. If it is not possible, then conflict will arise anyway so punch those that try to stop you. In conclusion the only strategy that wins in all cases is that of doing what you want against all adversity, as long as you respect that right in others.
|
Seagel Neville
Far East User
Join date: 2 Jan 2005
Posts: 1,476
|
08-12-2005 08:23
 Gee! Jesrad, thank you. How clevar you are! What a fast response! I've been stuck with this for even over a day....  Thank you so much! 
_____________________
 Seagel Neville 
|
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
|
08-12-2005 08:50
As an alternative in this instance replace the removed key with the null key, check for the index of null key with listfindlist and if it's not there add it to the list, otherwise replace it. Jesrad's solution might well be faster though.
|
Seagel Neville
Far East User
Join date: 2 Jan 2005
Posts: 1,476
|
08-12-2005 09:10
Thank you, Eloise, I also thought like that. But I didn't know how to replace an element which was some specific place in the list. Edit: Sorry Eloise, I've just found llListReplaceList. So I could prepare a list whose element was just NULL_KEY and replace it. And I realized this idea was simpler. Because if a few ppl were dropped out in advance, Lists would be complex much more. Thank you.
_____________________
 Seagel Neville 
|
Blain Candour
Registered User
Join date: 17 Jun 2005
Posts: 83
|
08-14-2005 20:18
This is an old topic I know. But you could also just use an integer to store position and do away with all that finding. Before you delete someone set a variable integer to the position place. Then when you add someone else read that variable and plug the new person in at that point.
|
Seagel Neville
Far East User
Join date: 2 Jan 2005
Posts: 1,476
|
08-14-2005 20:55
Thank you. I'm glad to be told there was a lot of idea which I didn't figure out. My fault was that I thought I had to insert an element by using "+=". But there was only llListInsertList to insert it. It was list to list. So I realized that I could put it into a new list and use that funciton. llListReplaceList is also the same thing. I didn't have an idea such as making a list to insert in advance. But I learnd. Thank you all. 
_____________________
 Seagel Neville 
|