Jump to content

A Smart Chair Helps You (Un)Sit Gracefully


Rolig Loon
 Share

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

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

Recommended Posts

This falls into the category of silly but practical scripts.  If you place a chair at a table or desk, it's sometimes easy enough to sit (the sit target takes care of that), but you have no control over where the av ends up when s/he stands.  Unfortunately, s/he often ends up standing on the table or desk.  What you need is a smart chair that helps you sit gracefully and then UNsit just as gracefully.  Here's a script that does it, although you will of course want to customize it for your own circumstances.

// A Gentle Sitter/Unsitter  -- Rolig Loon -- 2015

// Free for general public use if you retain these top lines for attribution.

key Av;

default
{
    state_entry()
    {
        llSetClickAction(CLICK_ACTION_SIT);
        llSitTarget(<0.15,0.15,0.25>,ZERO_ROTATION);
    }

    changed (integer change)
    {
        if (change & CHANGED_LINK)
        {
            Av = llAvatarOnSitTarget();
            if(Av)
            {
                llSetClickAction(CLICK_ACTION_TOUCH);
                llSetPos(llGetPos() + <1.0,0,0>* llGetRot());
                llRequestPermissions(Av,PERMISSION_TRIGGER_ANIMATION);
            }
            else
            {
                llSetPos(llGetPos() + <-1.0,0,0> * llGetRot());
                llResetScript();
            }
        }
    }
    
    run_time_permissions (integer perm)
    {
        if (perm & PERMISSION_TRIGGER_ANIMATION)
        {
            llStopAnimation("sit");
            llStartAnimation(llGetInventoryName(INVENTORY_ANIMATION,0));
            state running;
        }
    }
}

state running
{
    touch_end(integer num)
    {
        llSetPos(llGetPos() + <-1.0,0,0> * llGetRot());
        llUnSit(Av);
        llResetScript();
    }
    
    changed (integer change)
    {
        if (change & CHANGED_LINK)
        {
            llSetPos(llGetPos() + <-1.0,0,0> * llGetRot());
            llResetScript();
        }
    }
}

So, add it to your chair, adjust the sit target as necessary, and add your own sit animation.  Place the chair about a meter from where you want the seated avatar to be.  When someone clicks to sit, the chair will move forward with the person.  When the person clicks the chair again, it will move backward and unseat the person into the open space in front of it, rather than up on the table. 

  • Like 5
Link to comment
Share on other sites

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