Jenny Carlos
Registered User
Join date: 30 Aug 2005
Posts: 52
|
08-30-2005 07:14
Hello there, Im rather new to sl scripting but have done some java stuff so this is rather simalar but has a few neat differances..
Anyway ive set up an object so that when its rezed it sends messages to another attachment on my avatar.. It seems to work fine.. BUT I need a way to send a closeing message when the object is put back into inventory..
Example : Lets say I have a pair of shoes on, I create listner and then a new object like maybe a ring on my finger. When the ring is attached it sends a command to the shoes that changes there color from white to blue lol.. This is all dandy But lets say I want the shoes to go back white when the ring is put away ? Is there a way for my script to know when the object is being taken back into inventory?
Thanks for any responces. Jenny Carlos
|
Slayd Lemieux
Registered User
Join date: 9 Jul 2005
Posts: 29
|
Maybe...
08-30-2005 07:54
Taking your example, you could add a couple timers that may solve the problem. One on the ring that every 5-10 seconds or so will send a message to the boots. On the boots, have a timer set up so that if that message is not received once every 10-15 seconds (little longer just incase), it would return to it's normal color.
Easiest way I can think of, but I am also pretty new to scripting here.
Good luck!
|
Vanhal McGettigan
Keep Smiling Games Maker
Join date: 3 Jun 2005
Posts: 28
|
08-30-2005 08:29
if there both going to be woren just us attach instead of on_rez http://secondlife.com/badgeo/wakka.php?wakka=attachit will trigger when unattaching and attaching
|
Ushuaia Tokugawa
Nobody of Consequence
Join date: 22 Mar 2005
Posts: 268
|
08-30-2005 08:33
From: Jenny Carlos Is there a way for my script to know when the object is being taken back into inventory?
The mechanics of detaching an attachment and taking a rezzed object back into inventory are actually quite different. From your example, I take it that you mean "is there a way for my script to know when the object is being detached". If I'm reading you correctly, the answer is "Yes!".  When an object is detached, the attach event fires in any scripts running in that attachment just before it is put away. When an object is being detached, the id passed to the attach event is NULL_KEY. Using this, you could easily send a message to your other attachments at the right time. One caveat: I can't get in-world right now to confirm this, but I recall that the behaviour is actually a little flakey. If you attempt to send your message from within the attach event, I seem to recall that it won't fire properly. You actually have to switch states in order for this to work how I described.
|
Jenny Carlos
Registered User
Join date: 30 Aug 2005
Posts: 52
|
08-30-2005 09:19
Yes the timer system has been in my head but I dont think thats a really good idea to have so much messages being sent every couple seconds.. Im Sorry but yes I ment that attached Items lol..
I want the ring on my finger to send a message on a channel so that the shoes will pick it up .. Then when the ring is removed send a message back to change them back to normal..
I figured there had some way to do it.. I would love to see example of this in action so I know how to go about doing it..
Any code examples would be great..
Thanks guys Jenny Carlos
|
Rasputin Polonsky
Registered User
Join date: 13 Aug 2005
Posts: 9
|
08-30-2005 09:44
well as people have mentioned the attach event seems like a good idea default { attach(key attached) { if (attached != NULL_KEY) // object has been //attached// { llWhisper( 0, "I'm stuck on you, " + llKey2Name(attached) ); // etc. } else // object has been detached { llWhisper( 0, "Why hast thou forsaken me?" ); // etc. } } } http://secondlife.com/badgeo/wakka.php?wakka=attach
|