Objects sending keys for communication
|
|
Rigrunner Rang
...Newb
Join date: 23 May 2007
Posts: 162
|
11-11-2007 05:07
Hey all, I'd like to have one big object which other smaller objects can interact with. However I wouldn't want the smaller objects to get confused with each other, they're all independent. So using the average llSay for communication between objects seems out of the question unless each smaller object spoke on a different channel urgh... I'm hoping there's a way I can set up object keys, so the small object can send it's key to the big object before any communication takes place or something along those lines! Perhaps there's a better way to go about it? I'm stuck so it's over to you... What's the best way to have multiple objects communicating with one main object? Thanks 
_____________________
Visit Knockout! http://slurl.com/secondlife/Junlong/164/135/51
|
|
Ace Cassidy
Resident Bohemian
Join date: 5 Apr 2004
Posts: 1,228
|
11-11-2007 05:19
There is no object-to-object IM capability in LSL, so your only communications scheme is to use llSay.
However, it is fairly straightforward to map an object's key to a communications channel. A key is really nothing but a 128-bit number represented as a series of 32 hex digits interspersed with some dashes.
You could take the last 8 of these hex digits, and convert that into a channel number for communicating with the specific object. You do have a very small probability of two different objects using the same channel (1 in approximately 4 billion), which you could either discount, or code for.
- Ace
_____________________
"Free your mind, and your ass will follow" - George Clinton
|
|
Ordinal Malaprop
really very ordinary
Join date: 9 Sep 2005
Posts: 4,607
|
11-11-2007 05:34
Or you can use the same channel for everything but have the object check for its key in the message first. I posted an example of some code for this sort of thing in my forum here: http://ordinalmalaprop.com/forum/discussion/21/beginners-question-object-communication/#Comment_127
_____________________
http://ordinalmalaprop.com/forum/ - visit Ordinal's Scripting Colloquium for scripting discussion with actual working BBCode!
http://ordinalmalaprop.com/engine/ - An Engine Fit For My Proceeding, my Aethernet Journal
http://www.flickr.com/groups/slgriefbuild/ - Second Life Griefbuild Digest, pictures of horrible ad griefing and land spam, and the naming of names
|
|
Ace Cassidy
Resident Bohemian
Join date: 5 Apr 2004
Posts: 1,228
|
11-11-2007 10:53
From: Ordinal Malaprop Or you can use the same channel for everything but have the object check for its key in the message first. I don't usually like to slam other's suggestions, but if the number of objects is large, then Ordinal's approach does have the serious drawback of triggering a listen in every object, for every message that is sent out. Setting up a separate channel for each object will be significantly less lag-inducing, especially for a large number of listening objects. - Ace
_____________________
"Free your mind, and your ass will follow" - George Clinton
|
|
Ordinal Malaprop
really very ordinary
Join date: 9 Sep 2005
Posts: 4,607
|
11-11-2007 13:48
It will, yes, if there are many objects. On the other hand, calculating a channel from the key always has an overhead, and will not necessarily be unique; furthermore, for rapid communication it may take a little while to establish a listen on a channel (this does make a difference with very-short-lifespan objects, believe me). So it will really depend on the application.
_____________________
http://ordinalmalaprop.com/forum/ - visit Ordinal's Scripting Colloquium for scripting discussion with actual working BBCode!
http://ordinalmalaprop.com/engine/ - An Engine Fit For My Proceeding, my Aethernet Journal
http://www.flickr.com/groups/slgriefbuild/ - Second Life Griefbuild Digest, pictures of horrible ad griefing and land spam, and the naming of names
|
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
11-11-2007 15:22
also to avoid all objects hearing on the same channel, you can do a few things
1) sub objects speak on 1 channel, listen on another
2)main object assigns an individual channel based on the order it heard sub objects, they listen for specific commands on that channel
3) prefix commands with a key phrase, then look for that key phrase at the begining of the line -eg if(llSubStringIndex( string_message, "key Phrase" ) == 0){ //-- process
that avoids others objects on the same channel accidentally getting processed by your object, it also helps process different commands
speaker name, and key are both available through the listen event, so can easily be captured for storage by main object, in a list, then used to address each individual object by name
there was a thread about saving strings to integers to save time (that didn't work, because of screwy lsl storage sizes) but I added a base 64 converter that saves 25% of the key space, and as a bonus obscures the key
_____________________
| | . "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... | - 
|
|
Johan Laurasia
Fully Rezzed
Join date: 31 Oct 2006
Posts: 1,394
|
11-12-2007 02:46
How Void is suggesting is exactly how I do it. I have a teleporter system I'm working on that must communicate via the master (last rezzed) pad, and the other (slave) pads. When I query the slave pads they all bark back their info in the format of name : position. When the master wants to communicate information to a specific object, it formats the data in the format of name:info. All the other scripts hear the info, but only the one with the proper name takes action. It's sort of like how cellphones, pagers, cable boxes, computer networking, etc, all works. Simple, one channel communication seems to work best for me.
|
|
Rigrunner Rang
...Newb
Join date: 23 May 2007
Posts: 162
|
11-12-2007 05:46
thanks for the feedback and suggestions everyone, it's appreciated.
There's a lot to get my head around here in the thread (still a newbie scripter) but it makes sense too. I just hope i can put my brain in gear and get a script going.
Cheers!
_____________________
Visit Knockout! http://slurl.com/secondlife/Junlong/164/135/51
|