Jump to content

Script act on sitting/standing


Surssin
 Share

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

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

Recommended Posts

I swear I've tried to find ways to do it, so I'm probably looking right past some simple example.

I want to have an attachment react to the wearer sitting vs not sitting. Both when it's attached, or just "oh hey, you're sitting now. We're going to do X. Oh you stood up? Okay. We'll do Y."

I'm confident I can get it to do what I want it too when those states are detected, but I can't figure out how to get it to detect sitting vs not. I saw about the llGetAgentInfo, but I'm at a loss as to how to use that to do what I'm looking for.

P.S. Noob scriptor. Forgive me missing anything simple. :)

Link to comment
Share on other sites

If you care what the avatar is sitting on, you can use llGetObjectDetails, OBJECT_ROOT , but you still have to check on a timer (or maybe a control event but that would be kinda wonky, I'm almost tempted to try that with llSetMinEventDelay to see if it would reasonably work though.)

ETA: if you don't need to detect ground sits, this mostly works:

integer gSitting;
default
{   state_entry()
    {   llMinEventDelay(2.0);
    }
    attach(key ID)
    {   if(ID) llRequestPermissions(ID,PERMISSION_TAKE_CONTROLS);
    }
    run_time_permissions(integer perms)
    {   if(perms&PERMISSION_TAKE_CONTROLS) llTakeControls(0x06000300,TRUE,TRUE);
        // 0x06000000 is the sum of the undocumented left+right 'rotation detected' controls.
        // 0x300 is normal left+right rotation.
    }
    control(key ID, integer level, integer edge)
    {   integer sitting = llGetAgentInfo(ID)&(AGENT_SITTING|AGENT_ON_OBJECT);
        if(sitting!=gSitting)
        {   gSitting=sitting;
            if(gSitting)
            {   llOwnerSay("Is sitting");
            }else
            {   llOwnerSay("Has stood up");
            }
            llOwnerSay((string)sitting);
        }
    }
}

but if you're not that hyper-concerned about efficiency and need ground-sit detection, then just replace the control event with a timer, and set the timer in state_entry instead of the minEventDelay, and remove the attach and run_time_perms events.

 

Edited by Quistess Alpha
  • Like 1
  • Thanks 1
Link to comment
Share on other sites

I don't care what I'm sitting on. It's all about "am I sitting?"

I managed to man-handle the example into accurately detecting sit on attach. So that's one part down. Thanks for that.

Now I just need help with the timer part, or whatever I need, to have it detect when I stand up.

Edited by Surssin
  • Like 1
Link to comment
Share on other sites

51 minutes ago, Quistess Alpha said:

If you care what the avatar is sitting on, you can use llGetObjectDetails, OBJECT_ROOT , but you still have to check on a timer (or maybe a control event but that would be kinda wonky, I'm almost tempted to try that with llSetMinEventDelay to see if it would reasonably work though.)

ETA: if you don't need to detect ground sits, this mostly works:

integer gSitting;
default
{   state_entry()
    {   llMinEventDelay(2.0);
    }
    attach(key ID)
    {   if(ID) llRequestPermissions(ID,PERMISSION_TAKE_CONTROLS);
    }
    run_time_permissions(integer perms)
    {   if(perms&PERMISSION_TAKE_CONTROLS) llTakeControls(0x06000300,TRUE,TRUE);
        // 0x06000000 is the sum of the undocumented left+right 'rotation detected' controls.
        // 0x300 is normal left+right rotation.
    }
    control(key ID, integer level, integer edge)
    {   integer sitting = llGetAgentInfo(ID)&(AGENT_SITTING|AGENT_ON_OBJECT);
        if(sitting!=gSitting)
        {   gSitting=sitting;
            if(gSitting)
            {   llOwnerSay("Is sitting");
            }else
            {   llOwnerSay("Has stood up");
            }
            llOwnerSay((string)sitting);
        }
    }
}

but if you're not that hyper-concerned about efficiency and need ground-sit detection, then just replace the control event with a timer, and set the timer in state_entry instead of the minEventDelay, and remove the attach and run_time_perms events.

 

hm, when I try it, I don't get the responses when I sit on something. I'll try the adjustments you mentioned after work.

Unless someone has a different way to do it.

Link to comment
Share on other sites

I can't seem to get it to work. I can get it to detect if I'm sitting when I attach it, but I can't get a timer to recheck the status of sitting/not.

My best effort.

integer gSitting;
integer sit;
key ID;
default
{
   state_entry()
    {
   llSetTimerEvent(5.0);
    }
    attach(key ID)
    {  
        sit = llGetAgentInfo(ID);
        if (sit & AGENT_SITTING)
            {
                llOwnerSay("Is sitting");
            }
            else
            {
                llOwnerSay("Has stood up");
            }
        }
    timer()
    {
        key ID;
        integer sitting = llGetAgentInfo(ID)&(AGENT_SITTING|AGENT_ON_OBJECT);
        if(sitting!=gSitting)
        {
            gSitting=sitting;
            if(gSitting)
            {
                llOwnerSay("Is sitting");
            }
            else
            {
                llOwnerSay("Has stood up");
            }
            llOwnerSay((string)sitting);
        }
    }

}

Edited by Surssin
Link to comment
Share on other sites

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