Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Please help - make my objects pass avatar info?

Kat Claxton
Encore Design Group
Join date: 13 Oct 2006
Posts: 47
11-27-2007 15:37
Hello,

I'm at a loss - I need a script that will make an object talk to another object when touched, and will pass enough info to the listening object for it to be able to give an inventory item to the toucher. Basically the flow is:

1) Joe Blow touches object A
2) Object A says "yo, I was touched by Joe Blow" to object B on channel whatever
3) Object B gives Joe Blow an object or notecard or whatever I tell it to give out

I have the basic concept of touch_start and say blah blah blah on channel such and such for object A, and I know how to make an object give inventory. Where I am getting stuck is that I don't quite know how to pass the avatar info from A, or have B listen, recognize the avatar info, and give them something. It seems like it should be a fairly simple process, but I am totally stuck.

Please help?
Nika Talaj
now you see her ...
Join date: 2 Jan 2007
Posts: 5,449
11-27-2007 15:59
If the two objects are linked, you can use llMessageLinked, which will trigger a linkmessage event in the object to which the message is sent:
http://www.lslwiki.net/lslwiki/wakka.php?wakka=llMessageLinked

There are numerous other examples in the forums, search for linkmessage.

If the two objects are not linked, then you should use chat between them, preferably on an obscure channel.
_____________________
.
:) To contact forum folks, join the inworld group "The Forum Cartel". New residents with questions about SL more than welcome! We has parties!

:) To contact forum scripters, join the inworld group "Scriptoratti" (thanks Void!). New scripter questions welcome!
Kat Claxton
Encore Design Group
Join date: 13 Oct 2006
Posts: 47
11-27-2007 16:14
Thanks for your reply Nika, but maybe I'm not being clear.

I need the code that allows object A to tell object B WHO touched it, and the code that allows object B to know who touched object A so it will then know who to give inventory to. And the prims won't be linked, so it all has to take place on a chat channel.
Nika Talaj
now you see her ...
Join date: 2 Jan 2007
Posts: 5,449
11-27-2007 16:49
Do you mean you need to know how to identify the toucher and pass the info? If so, something like (please forgive the style, trying to be concise):

Object A gets a touch event and does something like:

touch_start(integer num)
{

llSay (4012, llDetectedKey(0) + "*" + llDetectedName(0) ) ;
}


Object B installed a listener on the right channel for the object ID, if you want to get that specific.


init()
{
llListenRemove (handle);
handle = llListen (4012, "",objectA_Id,"";);
...

} //end init Object B


And then object B processes the listen event when it gets it:

listen(integer channel, string name, key id, string message)
{
list messageList;

messageList = llParseString2List(message,["*"],[]);

and at this point the first list item is the key, the second is the name.

....
_____________________
.
:) To contact forum folks, join the inworld group "The Forum Cartel". New residents with questions about SL more than welcome! We has parties!

:) To contact forum scripters, join the inworld group "Scriptoratti" (thanks Void!). New scripter questions welcome!
Kat Claxton
Encore Design Group
Join date: 13 Oct 2006
Posts: 47
11-27-2007 17:10
From: Nika Talaj
Do you mean you need to know how to identify the toucher and pass the info?


Exactly.

This is what I have, that is very rudimentary and VERY broken, but please forgive me - I'm not a strong enough coder to get any further than this at the moment:

==============================================

Object A (the sender):

default
{
touch_start
{
llSay (123, "", llDetectedKey(0), "object";) ;
}
}

===============================================

Object B (the receiver)

default
{
state_entry()
{
llListen(123, "", llDetectedKey(0), "";);
}

listen( integer channel, string name, key id, string message )
{
if ( message == "object" )
{
llGiveInventory(llDetectedKey(0), "Object";);
}
}
}

========================================

Do you kind of see what I'm getting at?

I'm getting very sad and desperate. :(
Kat Claxton
Encore Design Group
Join date: 13 Oct 2006
Posts: 47
11-27-2007 18:29
A good friend of mine showed up and was able to put this together for me. :)

I want to thank you again Nika for responding, I wish I had been smart enough to understand your help better.
Nika Talaj
now you see her ...
Join date: 2 Jan 2007
Posts: 5,449
11-27-2007 19:11
Glad you got it straightened out!
_____________________
.
:) To contact forum folks, join the inworld group "The Forum Cartel". New residents with questions about SL more than welcome! We has parties!

:) To contact forum scripters, join the inworld group "Scriptoratti" (thanks Void!). New scripter questions welcome!