Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Saving locations from one listen?

Okiphia Rayna
DemonEye Benefactor
Join date: 22 Sep 2007
Posts: 2,103
12-14-2007 09:20
OK, seems like this should be pretty simple and I'm just trying too hard but oh well.

I want to be able to keep multiple variables from one listen event, with different names and location vectors for each.

It's listening on one channel for any reply from anything, saying 'I'm here'. If it hears that, I want it to keep that objects location and name, and any others it hears. However, so far the only way I've figured it out to work is to actually have multiple listen events where if it hears a specific object, it will keep that object, and just have that for each named one.. but I want them to be able to be named by the user.

Any ideas?

Essentially, I want it to keep the location of EVERY object that replies to it, without it already knowing the names. Is there some way I can do this?
_____________________
Owner of DemonEye Designs Custom Building and Landscaping
Owner and Blogger, Okiphia's Life
http://okiphiablog.blogspot.com/
Atashi Toshihiko
Frequently Befuddled
Join date: 7 Dec 2006
Posts: 1,423
12-14-2007 09:32
Use a list to store the results.

In your listen event you'll get the name of the object that is doing the speaking, along with what it says. Do something like this:

CODE

listen(integer channel, string name, key id, string message) {
integer index = llListFindList(myList, [name]);
if(index == -1) {
// not on list so add them
myList += [name, (vector)message];
} else {
// already on the list, so just update what they said
llListReplaceList(myList, [(vector)message], index+1, index+1);
}
}


That assumes that the objects that are speaking are basicaly just saying their location, like this:
llSay(channel, (string)llGetPos());

So they say their location, the listening object hears them and captures their name and their location and updates the list. The list is a global variable so you can access it in other events.

-Atashi
_____________________
Visit Atashi's Art and Oddities Store and the Waikiti Motor Works at beautiful Waikiti.
Okiphia Rayna
DemonEye Benefactor
Join date: 22 Sep 2007
Posts: 2,103
12-14-2007 09:35
I was thinking there would be some way to do it with a list..

Thanks much ^_^
_____________________
Owner of DemonEye Designs Custom Building and Landscaping
Owner and Blogger, Okiphia's Life
http://okiphiablog.blogspot.com/
Xhawkx Holden
Registered User
Join date: 1 Nov 2006
Posts: 86
12-14-2007 09:44
Just don't put in a name in the llListen function and NULL_KEY for the key

llListen(50,"",NULL_KEY,"";);

This will allow you to hear messages from any object speaking on channel 50
Okiphia Rayna
DemonEye Benefactor
Join date: 22 Sep 2007
Posts: 2,103
12-14-2007 09:49
Using the list thingy above (Function? call? w/e), would it be possible to have it listen for a specific message other than the position, and have it still store the location? Just realized that if I have it shouting out its location then I can't have things react specifically the way I want.

I'm on the wiki trying to learn list stuff atm ^_^
_____________________
Owner of DemonEye Designs Custom Building and Landscaping
Owner and Blogger, Okiphia's Life
http://okiphiablog.blogspot.com/
Atashi Toshihiko
Frequently Befuddled
Join date: 7 Dec 2006
Posts: 1,423
12-14-2007 10:56
You can't 'detect' the position directly from a listen event (unlike sensors, touch, etc) but you could have the speaking objects say both a 'command' (or whatever) plus their location, then parse the results when you get them.

So the objects would say something like this:
llSay(channel, command + "|" + (string)llGetPos());

Where the command is a string that you want to capture and use, the | is a delimiter, and then the position is at the end.

Then in your listen event, you need to parse the message you receive to separate the command string from the location vector:
listen(integer channel, string name, key id, string message) {
list temp = llParseString2List(message, ["|"], []);
string command = llList2String(temp, 0);
string temp2 = llList2String(temp, 1);
vector position = (vector)temp2;
// now you can act on the command and record the name and the position in another list.
}

-Atashi
_____________________
Visit Atashi's Art and Oddities Store and the Waikiti Motor Works at beautiful Waikiti.
Okiphia Rayna
DemonEye Benefactor
Join date: 22 Sep 2007
Posts: 2,103
12-14-2007 11:00
From: Atashi Toshihiko
You can't 'detect' the position directly from a listen event (unlike sensors, touch, etc) but you could have the speaking objects say both a 'command' (or whatever) plus their location, then parse the results when you get them.

So the objects would say something like this:
llSay(channel, command + "|" + (string)llGetPos());

Where the command is a string that you want to capture and use, the | is a delimiter, and then the position is at the end.

Then in your listen event, you need to parse the message you receive to separate the command string from the location vector:
listen(integer channel, string name, key id, string message) {
list temp = llParseString2List(message, ["|"], []);
string command = llList2String(temp, 0);
string temp2 = llList2String(temp, 1);
vector position = (vector)temp2;
// now you can act on the command and record the name and the position in another list.
}

-Atashi


You can get the listening object to say the position though...

llSay(0, llGetObjectDetails(id,[OBJECT_NAME, OBJECT_POS]);
is that not 'detecting' its location? in my final script on 'regionsay talkback' it shows that line above actually in use and working.

I just want to understand it all ^_^
_____________________
Owner of DemonEye Designs Custom Building and Landscaping
Owner and Blogger, Okiphia's Life
http://okiphiablog.blogspot.com/
Atashi Toshihiko
Frequently Befuddled
Join date: 7 Dec 2006
Posts: 1,423
12-14-2007 11:32
From: Okiphia Rayna
You can get the listening object to say the position though...

llSay(0, llGetObjectDetails(id,[OBJECT_NAME, OBJECT_POS]);
is that not 'detecting' its location? in my final script on 'regionsay talkback' it shows that line above actually in use and working.

I just want to understand it all ^_^


Yeah, that will appearantly work too :P

You kids and your newfangled LSL functions... they didn't have llGetObjectDetails when I was young, you know. We had to do it the hard way. :)

-Atashi
_____________________
Visit Atashi's Art and Oddities Store and the Waikiti Motor Works at beautiful Waikiti.
Okiphia Rayna
DemonEye Benefactor
Join date: 22 Sep 2007
Posts: 2,103
12-14-2007 11:54
From: Atashi Toshihiko
Yeah, that will appearantly work too :P

You kids and your newfangled LSL functions... they didn't have llGetObjectDetails when I was young, you know. We had to do it the hard way. :)

-Atashi

lol okies cool, thanks then


*looks up, eyes shining* What was it like in 2006?
_____________________
Owner of DemonEye Designs Custom Building and Landscaping
Owner and Blogger, Okiphia's Life
http://okiphiablog.blogspot.com/
Deanna Trollop
BZ Enterprises
Join date: 30 Jan 2006
Posts: 671
12-14-2007 15:22
From: Atashi Toshihiko
You kids and your newfangled LSL functions... they didn't have llGetObjectDetails when I was young, you know. We had to do it the hard way. :)

40 miles... in the snow... uphill... both ways...
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
12-14-2007 15:30
this will store any message starting with 'key word' (which will be ommited) in a list with the name of the object speaking... or you could add a name to the message, and use llParseString2List... it will also update new info for names that repeat
CODE

listen (integer channel, string name, key id, string heard)
if(!llSubStringIndex("key word", heard){ //-- check to make sure key word starts the message
heard = llGetSubString( heard, <insert keyword length>, -1 );
integer index = llListFindList( StorageList, (list)heard );
if (~index){
StorageList = llListReplace( StorageList, [heard, name], index, index + 1 );
}else{
StorageList += [heard, name];
}
}
}
_____________________
|
| . "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...
| -