Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

alternative_llResetScript?!

Pari Thor
Registered User
Join date: 24 Jun 2008
Posts: 10
06-25-2008 04:39
hello,
i am trying to make 2 objects communicating with eachother and getting infos from the avatars nearby and passing it on to the objects,
so this is the script of my sensorobject(in the inventory of this i have the child object)
and my problem is in the last line of this script, i wanted the whole procedure to be repeated just the key_list shouldnt get empty by the second running of the script,...but i have no idea how...thnx for ur help,

string avKey;
integer list_pos;
list key_list;
integer key_chan;
integer die_chan = -1111;
integer key_rem_chan = -2222;

default {
state_entry() {
llSetObjectName("Sensor";);
llSensorRepeat("", "", AGENT, 5, PI, 1);
key_list =[];
llListen(key_rem_chan, "", "", "";);
}

sensor(integer iNum) {
integer p = 0;
for (p = 0; p < iNum; ++p) {
avKey = llDetectedKey(p);
list_pos = llListFindList(key_list,[avKey]);
if (list_pos == -1) {
key_list = (key_list =[]) + key_list +[avKey];
key_chan = (integer)llFrand(-1000000) - 1000000;
llRezObject("scan ball", llGetPos(), ZERO_VECTOR, ZERO_ROTATION, key_chan);

llSleep(.25);
llRegionSay(key_chan, avKey);}
}
}

listen(integer c, string name, key id, string msg) {
key remove_key = msg;
integer r = llListFindList(key_list,[remove_key]);
llDeleteSubList(key_list, r, r);
Scan=FALSE;
llResetScript(); //shouldnt delete the key list!!but how?!
}

}
Senuka Harbinger
A-Life, one bit at a time
Join date: 24 Oct 2005
Posts: 491
06-25-2008 05:14
try adding in a switching state?

in your listen event, call for state switch instead of llResetScript()


CODE

state switch
{
state_entry()
{
state default;
}
}
_____________________
My SLExchange shop

Typos are forgiven; desecrating the english language with reckless abandon and necrophilic acts is not.


The function is working perfectly fine. It's just not working the way you wanted it to work.
Dora Gustafson
Registered User
Join date: 13 Mar 2007
Posts: 779
06-25-2008 06:21
What is a "second run"?
it is the script reset that trigger state_entry() in your default and clear the list.
Do you need a script reset? if so, what is it for?
_____________________
From Studio Dora
Pari Thor
Registered User
Join date: 24 Jun 2008
Posts: 10
still no result;
06-25-2008 07:09
hi, i did as u suggested, now i dont get any balls rezzed anymore, thats really weired it should acctually function...isnt that so that the defined variable at the top stays the same in the different states?
now it look like this:

string avKey;
integer list_pos;
list key_list;
integer key_chan;
integer die_chan = -1111;
integer key_rem_chan = -2222;

default {
state_entry() {
llSetObjectName("Sensor";);
llSensorRepeat("", "", AGENT, 5, PI, 1);
key_list =[];
llListen(key_rem_chan, "", "", "";);
}

sensor(integer iNum) {
integer p = 0;
for (p = 0; p < iNum; ++p) {
avKey = llDetectedKey(p);
list_pos = llListFindList(key_list,[avKey]);
if (list_pos == -1) {
key_list = (key_list =[]) + key_list +[avKey];
key_chan = (integer)llFrand(-1000000) - 1000000;
llRezObject("scan ball", llGetPos(), ZERO_VECTOR, ZERO_ROTATION, key_chan);

llSleep(.25);
llRegionSay(key_chan, avKey);}
}
}

listen(integer c, string name, key id, string msg) {
key remove_key = msg;
integer r = llListFindList(key_list,[remove_key]);
llDeleteSubList(key_list, r, r);
state switch;

}

}


state switch
{
state_entry() {
llSetObjectName("Sensor";);
llSensorRepeat("", "", AGENT, 5, PI, 1);
//key_list =[]; i have deleted this line for the state switch!
llListen(key_rem_chan, "", "", "";);
}
....etc. just like the default state!

now it rezzez the object just once, then not anymore..
Pari Thor
Registered User
Join date: 24 Jun 2008
Posts: 10
06-25-2008 07:21
------What is a "second run"?
it is the script reset that trigger state_entry() in your default and clear the list.
Do you need a script reset? if so, what is it for?------

i have some object which get rezzed and they send a message on key_rem_chan and the sent message will be one of the keys which should be deleted from the key_list, and the sensor should on the next run" find the avatar with that key again and add it to the list... and rez an object to it again, now u see i reset the script so that it listens again to the rem channel and repeats the sensoring...
Dora Gustafson
Registered User
Join date: 13 Mar 2007
Posts: 779
06-25-2008 07:35
yes and in both "state_entry()" you clear your list: key_list =[];
right?
_____________________
From Studio Dora
Pari Thor
Registered User
Join date: 24 Jun 2008
Posts: 10
06-25-2008 07:40
no i deleted it just from the switch state not from the default state, and at the end of the switch state in the listen event i have again turn to switch state..
Johan Laurasia
Fully Rezzed
Join date: 31 Oct 2006
Posts: 1,394
06-25-2008 08:05
You need to post the changes then so we can see.


http://www.secondscripter.com
_____________________
My tutes
http://www.youtube.com/johanlaurasia
Pari Thor
Registered User
Join date: 24 Jun 2008
Posts: 10
06-25-2008 08:27
Ok, its a bit long but hope someone reads and helps me...
what happens is that it rezzez just once...also the object in the inventory of this object is sending on the key_rem_chan, the id of the avatar, so that this object delets the id of that avatar from the list of the avatars (key_list) and so that the avatar gets a new object again rezzed to it...
but that doesnt seem to happen..:((


string avKey;
integer list_pos;
list key_list;
integer key_chan;
integer die_chan = -111;
integer key_rem_chan = -222;

default {
state_entry() {
llSetObjectName("sensor";);
key_list =[];
llSensorRepeat("", "", AGENT, 10, PI, 1);
llListen(key_rem_chan, "", "", "";);


}

touch_start(integer total_number) {

llRegionSay(die_chan, "die";);
state again;

}

sensor(integer iNum) {
integer p = 0;
for (p = 0; p < iNum; ++p) {
avKey = llDetectedKey(p);
list_pos = llListFindList(key_list,[avKey]);
if (list_pos == -1) {
key_list = (key_list =[]) + key_list +[avKey];
key_chan = (integer)llFrand(-1000000) - 1000000;
llRezObject("scan ball", llGetPos(), ZERO_VECTOR, ZERO_ROTATION, key_chan);

llSleep(.25);
llRegionSay(key_chan, avKey);}

}
}

listen(integer c, string name, key id, string msg) {
key remove_key = msg;
integer r = llListFindList(key_list,[remove_key]);
llDeleteSubList(key_list, r, r);
state again;

}

}


state again{
state_entry() {
llSetObjectName("sensor";);
llSensorRepeat("", "", AGENT, 7, PI, 1);
llListen(key_rem_chan, "", "", "";);
}

touch_start(integer total_number) {

llRegionSay(die_chan, "die";);
state again;

}

sensor(integer iNum) {
integer p = 0;
for (p = 0; p < iNum; ++p) {
avKey = llDetectedKey(p);
list_pos = llListFindList(key_list,[avKey]);
if (list_pos == -1) {
key_list = (key_list =[]) + key_list +[avKey];
key_chan = (integer)llFrand(-1000000) - 1000000;
llRezObject("scan ball", llGetPos(), ZERO_VECTOR, ZERO_ROTATION, key_chan);
llSleep(.25);
llRegionSay(key_chan, avKey);}

}
}

listen(integer c, string name, key id, string msg) {
key remove_key = msg;
integer r = llListFindList(key_list,[remove_key]);
llDeleteSubList(key_list, r, r);
state again;

}

}
Destiny Niles
Registered User
Join date: 23 Aug 2006
Posts: 949
06-25-2008 08:31
No alternative needed. LSL is event-based. Which means the senor event will trigger repeat itself without you resetting anything. You might want to add some no_sensor event code to delete stray balls.
Also are you sure it is no rezzing the scan ball, you have it rezzing in the center of your scan object, you might not be seeing it.
Pari Thor
Registered User
Join date: 24 Jun 2008
Posts: 10
06-25-2008 08:41
no i have made this object phantom and transparent, it rezzez once and then not anymore, like its not listening to the rezzed object ..,still have no idea why it doesnt rezz the objects again...
when i write it like this:

string avKey;
integer list_pos;
list key_list;
integer key_chan;
integer die_chan = -111;
integer key_rem_chan = -222;

default {
state_entry() {
llSetObjectName("sensor";);
key_list =[];
llSensorRepeat("", "", AGENT, 10, PI, 1);
llListen(key_rem_chan, "", "", "";);
}

touch_start(integer total_number) {
llRegionSay(die_chan, "die";);
}

sensor(integer iNum) {
integer p = 0;
for (p = 0; p < iNum; ++p) {
avKey = llDetectedKey(p);
list_pos = llListFindList(key_list,[avKey]);
if (list_pos == -1) {
key_list = (key_list =[]) + key_list +[avKey];
key_chan = (integer)llFrand(-1000000) - 1000000;
llRezObject("scan ball", llGetPos(), ZERO_VECTOR, ZERO_ROTATION, key_chan);
llSleep(.25);
llRegionSay(key_chan, avKey);}
}
}

listen(integer c, string name, key id, string msg) {
key remove_key = msg;
integer r = llListFindList(key_list,[remove_key]);
llDeleteSubList(key_list, r, r);

}
}
Destiny Niles
Registered User
Join date: 23 Aug 2006
Posts: 949
06-25-2008 08:53
Found your problem in the llDeleteSubList(key_list, r, r) you need to save the new list.
Should be
key_list = llDeleteSubList(key_list,r,r);
Pari Thor
Registered User
Join date: 24 Jun 2008
Posts: 10
06-25-2008 08:55
oh u are a genius! thank u a loooot!
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
06-25-2008 16:00
I've move the caveat for llDeleteSubList up higher on the page so it's more visible and expanded the description of it.

https://wiki.secondlife.com/wiki/LlDeleteSubList
_____________________
Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river.
- Cyril Connolly

Without the political will to find common ground, the continual friction of tactic and counter tactic, only creates suspicion and hatred and vengeance, and perpetuates the cycle of violence.
- James Nachtwey
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
06-25-2008 16:49
It might be much easier if you explained what you are trying to achieve different from the original script:

/54/e4/226472/1.html
_____________________
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