Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Communication with attachments

Kayaker Magic
low carbonated footprint
Join date: 11 Sep 2008
Posts: 109
05-19-2009 20:09
I have a scripted vehicle that works in unison with an attachment. I want the vehicle to refuse to work unless you are wearing the attachment. If you are not, I want the vehicle to unseat you, llGiveInventory you the attachment and give you instructions on how to set everything up. So what is the best way to detect the attachment? I can get the key of the avatar who touches or sits on my vehicle, but I can’t look at his attachments and see if one of them is the right one. Or can I? I can’t use a fixed channel number to talk to the attachment because I want to allow multiple vehicle/attachment pairs near each other. How do I know if the one I want exists? I’m considering sending the avatar key back and forth in all communications to act as the unique ID of the pair communicating. Then I can use a single communications channel for all copies.
This all sounds messy, so before I get started, is there an easier way?
Imaze Rhiano
Registered User
Join date: 27 Dec 2007
Posts: 39
05-19-2009 23:48
1. You can use fixed channel or maybe unique channel created by sitter's id.
2. When avatar sits to object, object will send message to channel and specifies avatar.
3. Attachment in avatar hears message, and if avatar id is match - it will send reply message back to object. You might want to signature reply message with sha1, if you are worried about security.
4. If object doesn't hears attachment's reply message after certain time period, it will unsit avatar. If reply messages arrives - in time - then avatar is allowed to use object.
5. Object should periodially check that attachment is still rezzed (llKey2Name, llGetObjectDetails) and attachment should handle attached event to avoid case where user drops attachment to ground.
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
05-20-2009 00:06
you don't need to send the av key, or even use a unique channel.

just filter the listen by the owning av, and it doesn't matter if others are chattering on that channel, your object ignores it.
if (llGetOwnerKey( vKeySpeaker ) == llGetOwner())
do use some kind of command prefix so you don't have to worry about any other objects the av has
if (!llSubStringIndex( vStrHeard, command)){
(! means it must be at the beginning, or you can use ~ which will be true if it's in there at all.)
_____________________
|
| . "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...
| -