Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
|
05-07-2007 14:37
About a week and a half ago I figured out how to update sit targets. Upon chatting with a good friend it became apparent I wasn't the first and he gave me a bit of help on the size adjustment. Without his help I would have had to do a bunch of work myself, later he pointed out a bug in it, and with his feedback I was able to fix it. Escort deserves as much credit for this as myself. Anyway, here is the function, it updates the sit target, moving the avatar if one is seated. https://wiki.secondlife.com/wiki/llSitTarget //Sets / Updates the sit target moving the avatar on it if necessary. UpdateSitTarget(vector pos, rotation rot) { llSitTarget(pos, rot);//Set the sit target key user = llAvatarOnSitTarget(); if(user)//true if there is a user seated on the sittarget, if so update their position { vector size = llGetAgentSize(user); if(size)//This tests to make sure the user really exists. { //We need to make the position and rotation local to the current prim rotation localrot = ZERO_ROTATION; vector localpos = ZERO_VECTOR; if(llGetLinkNumber() > 1)//only need the local rot if it's not the root. { localrot = llGetLocalRot(); localpos = llGetLocalPos(); } pos.z += 0.4; integer linkNum = llGetNumberOfPrims(); do{ if(user == llGetLinkKey( linkNum ))//just checking to make sure the index is valid. { llSetLinkPrimitiveParams(linkNum, [PRIM_POSITION, ((pos - (llRot2Up(rot) * size.z * 0.02638)) * localrot) + localpos, PRIM_ROTATION, rot * localrot / llGetRootRotation()]); jump end;//cheaper but a tad slower then return } }while( --linkNum ); } else {//It is rare that the sit target will bork but it does happen, this can help to fix it. llUnSit(user); } } @end; }//Written by Strife Onizuka, size adjustment provided by Escort DeFarge
_____________________
Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river. - Cyril Connolly
Without the political will to find common ground, the continual friction of tactic and counter tactic, only creates suspicion and hatred and vengeance, and perpetuates the cycle of violence. - James Nachtwey
|
Talarus Luan
Ancient Archaean Dragon
Join date: 18 Mar 2006
Posts: 4,831
|
05-07-2007 16:20
Nice job, Strife!  Works well as far as I can tell. I had been meaning to play with the "user as a prim" trick for a while; chalk it up to too much work and not enough time to play! 
|
Sterling Whitcroft
Registered User
Join date: 2 Jul 2006
Posts: 678
|
05-08-2007 04:33
I have a bench that seats 4 in one prim. I used code from the forums...dated about 18 months ago, I think. Here's the link to Cua Curie's Multiple Location Sit code: /54/f8/64644/1.html And some discussion about which Avitars UUID is returned when several sit on one prim. /54/66/147510/1.html AND, see this recent code: /54/9c/182338/1.html#post1500497 
|
Kenn Nilsson
AeonVox
Join date: 24 May 2005
Posts: 897
|
05-08-2007 10:06
Wow...with all these code resources...I might have to go back to making furniture. I haven't done that since...wow...August, 2005  This stuff is great!
_____________________
--AeonVox--Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms chasing ghosts, eating magic pills, and listening to repetitive, addictive, electronic music.
|