Jump to content

Attachment: What am I sitting on?


Moon Corrigible
 Share

You are about to reply to a thread that has been inactive for 4354 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

I know I should know this but my brain is *just* not wrapping around it.

 

I from an attached object I am using:

 

      integer agentInfo = llGetAgentInfo(attached);

      if(agentInfo & AGENT_SITTING)

      {

                (Woo hoo I am a  lady of leisure!)

        }

 

To determine that my avatar is indeed sitting  - and this works wonderfully!  The problem is that I want to determine if my avatar is sitting on a particularly named chair - in this case 'MS Beta 1.0'.   Using llSensor does not work (I tried) it always returns a no_sensor event - I am guessing because the radius is 0.  (a sensor 1 m away picked up the chair just fine but my attached item returned a no_sensor).  And the key could be about anything because I want it to work for whatever rez of the chair I have out there.

 

So basically my question is:  Is there any way for an attached object to determine the name of the item an avatar is sitting on without having to have listeners going all of the time?

 

Thanks so much in advance!!

Link to comment
Share on other sites

This is still one of the big remaining holes in LSL. Avatars become child prims of what they sit on, but their attachments are blind to this.

You can play with status changes (llGetAgentInfo in the attachment, changed in the seat) to limit how long listeners are open. You could use a little delay, and maybe repeat the llRegionSayTo a few times, to allow the scripts on both ends to catch up.

Sensors in an attachment will not see an object you are sitting on because your avatar is linked to it. It's a special case of the limitation that attached sensors can't see their owners. This doesn't fix your problen but at least it's not just you =D

[A sensor to find the closest object may not work so well anyway, since objects can overlap and sit targets can be pretty far from the object.]

 

Link to comment
Share on other sites


you could use email if you dont want a listen going on?

something like this in the chair...

where ...5a634b27-f032-283f-2df2-55ead7724b23...is replaced by your HUD's key?

 

of course this only works for chairs you can put your scripts into....

 

 

default{ state_entry() { // set sit target, otherwise this will not work llSitTarget(<0.0, 0.0, 0.1>, ZERO_ROTATION); } changed(integer change) { if (change & CHANGED_LINK) { key av = llAvatarOnSitTarget(); if (av) // evaluated as true if key is valid and not NULL_KEY { llEmail("5a634b27-f032-283f-2df2-55ead7724b23@lsl.secondlife.com", "isSitting", "yes"); } } }}

 

 

Link to comment
Share on other sites

..I .. have.. no idea!  lol. 

 

I want the attachment to play one animation ('Hands Out') if the avatar is sitting on that particular chair and another ('Hands Folded') if it is doing anything else at all.  I have never used llEmail so I have no idea how it works!  Cool!!  New stuff!  I will play with it and let you know!!

Link to comment
Share on other sites

OK first off .. llEmail.. UBER cool!!  Thank you!!

 

But I need specific object keys to use it dont I?  And if the avatar is already sitting on the chair then the chair cant figure out the attachments key, and the attachment cant figure out the objects key.   ...  I think..  am I missing something?

 

Worse come to worst I can  fall back on checking the name of the animation playing and using that.  I dont *like* doing that because its a hefty list and it just feels inelegant and bulky.  But I think it will work if I sledgehammer it into place.  But either way I apprecaite the llEmail point... that is going to be HANDY!

 

Link to comment
Share on other sites

I'm not sure I understand exactly what you are asking for. Couldn't you put the script that triggers the "hands out" animation in the chair? It reads to me like you want a HUD or other object attached to your avatar to trigger the animation when you sit down. Honestly, I'm not sure how to do that. Do link messages work between objects sat on and attachments when  you are sitting?

Link to comment
Share on other sites

OK - to explain a little better - I made a bracelet that will control arms only animations.  The easiest parallel is holding a baby.  If theavatar standing or running or sitting in a different seat or doing virutally anything else I want it to play one animation.  But if I am sitting in one particular chair I want it to play a different animation because it just looks prettier.  (It isnt holding a baby by the way- lol).  I made the chair and the bracelet and the animations so that is all good.  I was just hoping for.. elegance - :)

Link to comment
Share on other sites

OK now I'm really being dense.

 

If I am using llRegionSayTo(key target, integer channel, string message) - I can not determine the key of the object I am sitting on from an attachment, so I would have to use a preset, hardcoded channel.  Yes?  And the chair would *have* to be listening on that particular hard coded channel the entire time anyone was sitting on it.  (Not that big a deal I know but I try to eliminate lag where I can)

Link to comment
Share on other sites

Unless you have a whole flock of attachments rezzed at the same time, each with a listener, don't worry about the small load that each one adds to the sim.  Listeners are not evil.  It's just blatant abuse of them that is.  There are plenty of times when having an open listser is a wise choice.This looks like one of them.

Having said that, you could try using your current trick to turn on a listener when the av sits, and then have each of your chairs scripted to send a "hello" ping when someone sits on it.  In the attachment, it would look something like this ...

timer(){    if (llGetAgentInfo() & AGENT_SITTING)   {        llListenRemove(gLisn); // I think you'll need to keep killing the listener each time to keep them from piling up        gLisn = llListen(my_chan,"","","");    // Open a temporary listener    }    else    {        llListenRemove(gLisn);    //Kill the listener    }}listen (integer channel, string name, key id, string msg){    if (name == "Chair1")    {        llStartAnimation("Hands Out");    }    else if (name == "Chair2")    {        llStartAnimation("Hands Folded");    }    llRegionSayTo(id,my_channel,"OK");    llListenRemove(gLisn);  // Kill the listener, receive no more pings}

  And in each chair it would look like ...

changed(integer change){    if(change & CHANGED_LINK)    {        gAv = llAvatarOnSitTarget();        if (gAv)        {            gLisn = llListen(gChan,"","","");    // Open a temporary listener            llSetTimerEvent(0.2);    //Start a fast ping            llRegionSayTo(gAv,0,"Ping");  //Ping will be heard by the attachment        }    }}timer(){    llRegionSayTo(gAv,0,"Ping");    //Repeated pings until a response is heard}listen(integer channel, string name, key id, string msg){    if (msg == "OK")    {        llSetTimerEvent(0.0);    // Ping was received, so stop pinging.        llListenRemove(gLisn);   // Kill the listener    }}

 That strategy gives you open listeners in the chair and the attachment for only a short burst of time, so you will have saved a tiny amount of load on the sim.  Of course, whether you use this method or not, the fast timer in your attachment that has to keep checking llGetAgentInfo is probably creating at least as much load.  

BTW, if you use e-mail, you should remember that you'll need to have llGetNextEmail in a fairly fast timer in order to hear the "hello" message from the chair.  Also remember that llEmail makes its script sleep for 20 seconds, so the chair will temporarily be deaf and blind as soon as the message is sent.

All in all, having an open listener in the attachment sounds like the best deal.

 

       

           

 

Link to comment
Share on other sites

In each chair ...

changed(integer change){    if (change & CHANGED_LINK)    {        key Av = llAvatarOnSitTarget();        if (Av)        {             llRegionSayTo(Av,gChan,llGetObjectName())); //Chair says its name to the Av.  Heard by the attachment        }    }}

 Yes, you would need to hard code gChan into the chairs and your attachments.  And put a listener in the attachments.  If you don't think you can remember the channel you used, try (integer)("0xF" + llGetSubString(llGetCreator(),0,6))  .  It's derived from your own UUID and unlikely to be in use by anyone nearby at the time.

 Edited to fix the inevitable typo  :smileyfrustrated:

Link to comment
Share on other sites

I think I have a sleazy way to do this without a listen, although I also agree with Rollig that a simple listen() is no big deal--and may in fact demand less of the sim than this approach (about which more below).

Because you control the seat's contents, you can arrange to add a unique animation to it that plays whenever an avatar sits there. (If it's already playing a non-unique anim, you can just push another, low-priority, mostly do-nothing anim on top of whatever anim it's already playing.) Then, when the attachment detects that its avatar is seated, it can check llGetAnimationList() for the UUID of that unique anim.

This might be a slight win over a listener iff the attachment otherwise checks the avatar's general animation state (using either llGetAnimation() or llGetAgentInfo()), as might an AO). Otherwise, adding that constant checking would be a significant net loss compared to the simple listener approach.

Link to comment
Share on other sites

Ah! now I get it. Wny not use a very tight listen filter in the bracelet and a whisper from the chair? Done right, this would be very low lag and have the advantage that you can tweek the bracelet for many different animations from many different chairs?

llListen(-99, chair_name, NULL_KEY, special_word); would be very low lag since your script would only be triggered for that exact message from items with that exact name. Using llWhisper(-99, special_word) would also reduce lag since it only goes 10m (which should be well above the range of you sitting on it).

 


Moon Corrigible wrote:

OK - to explain a little better - I made a bracelet that will control arms only animations.  The easiest parallel is holding a baby.  If theavatar standing or running or sitting in a different seat or doing virutally anything else I want it to play one animation.  But if I am sitting in one particular chair I want it to play a different animation because it just looks prettier.  (It isnt holding a baby by the way- lol).  I made the chair and the bracelet and the animations so that is all good.  I was just hoping for.. elegance -
:)



Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 4354 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...