Jump to content

llAvatarOnSitTarget() & Changed Link Event Specification


Artix Ruxton
 Share

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

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

Recommended Posts

Situation:

Prims A and B are child prims in a linkset, both which have sit targets. When an avatar sits on prim A, prim B's changed event is called. It then follows the codeblocks if(llAvatarOnSitTarget()), which returns false since the avatar is sitting on prim A. Therefore the else codeblock in prim B's changed event, which is supposed to only be triggered when an avatar stands up from prim B, is wrongfully triggered.  

Question:

How do i specify the difference between when an avatar sits on prim A and no one is sitting on prim B, versus when someone stands up from prim B?  Both events are cause the same block of code to execute.

-- Artix

Link to comment
Share on other sites

Use llAvatarOnSitTarget() in the change event. It will return a NULL_KEY if nothing is sat on it and and return the AVs key when sat on. So record the last key and current key. When the last key is not null someone just stood up from it. While a user is sitting do not check current key is not null or else you will get a false negative for some on standing up. 

Also note if you have a sit target it cannot be zero rotation and zero position.

key current_key = NULL_KEY;key last_key = NULL_KEY;default{    state_entry()    {        llSitTarget(<0,0,1>, <0,0,0,1>);    }    changed(integer change)    {        if(change & CHANGED_LINK)        {            current_key = llAvatarOnSitTarget();            if(current_key != NULL_KEY && current_key != last_key)            {                llOwnerSay("I was just sat on");            }            else if (last_key != NULL_KEY && last_key != current_key)            {                llOwnerSay("some one just stood up from me");               }            last_key = current_key;        }    }}

 

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 4722 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...