Surssin Posted April 12, 2023 Share Posted April 12, 2023 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 More sharing options...
Love Zhaoying Posted April 12, 2023 Share Posted April 12, 2023 Check out https://wiki.secondlife.com/wiki/LlGetAgentInfo. I think you would have to call it on a timer. Before llSetAnimationOverride(), we had to use llGetAgentInfo() to see what an avatar was "doing". Someone should be along to help answer if my answer is poor! 1 Link to comment Share on other sites More sharing options...
Quistess Alpha Posted April 12, 2023 Share Posted April 12, 2023 (edited) 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 April 12, 2023 by Quistess Alpha 1 1 Link to comment Share on other sites More sharing options...
Surssin Posted April 12, 2023 Author Share Posted April 12, 2023 (edited) 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 April 12, 2023 by Surssin 1 Link to comment Share on other sites More sharing options...
Surssin Posted April 12, 2023 Author Share Posted April 12, 2023 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 More sharing options...
Surssin Posted April 13, 2023 Author Share Posted April 13, 2023 (edited) 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 April 13, 2023 by Surssin Link to comment Share on other sites More sharing options...
Quistess Alpha Posted April 13, 2023 Share Posted April 13, 2023 26 minutes ago, Surssin said: timer() { key ID; you need to set that ID to the ID of the person wearing the object, which happens to always be the owner of the object: key ID = llGetOwner(); 2 Link to comment Share on other sites More sharing options...
Surssin Posted April 13, 2023 Author Share Posted April 13, 2023 That was the missing bit. I feel silly because I knew I needed the "GetOwner" part, but I couldn't add it without getting an error. Now I see what I was missing. It works as desired now. Thank you! 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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