Change font size
It is currently Wed May 22, 2013 6:58 pm

Forum rules


Image



Post a new topicPost a reply Page 1 of 1   [ 5 posts ]
Author Message
 Post subject: Attach from contents
PostPosted: Mon May 14, 2012 10:05 am 
Furious Typer
User avatar

Joined: Fri Aug 19, 2011 7:10 pm
Posts: 144
Location: Oldham, UK
OK, I'm not even sure that this is possible but:

Is there a way to attach an object contained in a prims contents when an avatar sits on the prim, and detach it again when they stand up. I don't mean attach the actual object that they sit on, but attach an object contained within the prim they sit on?

What I'm trying to achieve is to have a fishing stool attach a fishing rod to an avatars hand when they sit on the stool, and remove it again when they stand up.

llAttachToAvatar doesn't seem like it would achieve this itself, but I'm not 100% sure.

_________________
50's sim based at Rumbled on OSGrid
happily running on Arch Linux for 1 year +


Top
 Profile  
 
 Post subject: Re: Attach from contents
PostPosted: Mon May 14, 2012 2:49 pm 
OSG Elite
User avatar

Joined: Tue Aug 18, 2009 10:29 am
Posts: 392
Location: France
How you could do it is like this. Your fishing rod is set to alpha and linked in position to the stool, with an alpha poseball containing the fishing animation.
When the avatar sits on the visible stool, he would be in a fishing pose, while the scripts make the rod appear in his hand. When he jumps up the rod dissapears again!


Put this in each prim of the fishing rod

Code:
default
{
    state_entry()
    {
       
    }
   
    on_rez(integer start_param)
    {
        llResetScript();
    }
   
    link_message(integer sender_num, integer num, string str, key id)
    {
        if (str == "showfishingrod")
        {
            llSetAlpha(1,ALL_SIDES);           
        }
       
        if (str == "hidefishingrod")
        {
            llSetAlpha(0,ALL_SIDES);
        }
    }
}


And put this in a poseball containing animation and link together with fishing rod and stool

Code:
//Anxiousness Chair v.1
//By: Kaneda Akenbono
//Enjoy, and I'd appreciate it if you left this on the script. :)
//
//Add the animations you want to your object.
//I pulled the stuff below into globals so you can easily modify this script without understanding any of the code. :)

vector Angle = <0,0,0>; //Enter a vector rotation for the sit...
vector SitLoc = <0,0,0.1>; //This is the sitTarget positioning... CANNOT EQUAL 0
//string LoadText = "Anxiousnes Chair v.1 - Comment this out or change if you want..."; // The text you want to show when the object loads...
string Context = "Sit"; //The text you want in the context menu...

//Globals!! WOOO!!
key user;
key sitAgent = NULL_KEY;
list animations;
integer animNum;
integer nextAnim = 1;
integer curAnim = 0;
integer counter = 0;

//This part dynamically gathers all of the animations you've placed in the object for usage later...
initialize()
{
        integer x;
        list oldAnim;
        animNum = llGetInventoryNumber(INVENTORY_ANIMATION);
        for (x = 0; x < animNum; x++)
        {
            animations = oldAnim + [x];
            oldAnim = animations;
        }
        llMessageLinked(LINK_SET, 0, "showfishingrod", NULL_KEY);
         llMessageLinked(LINK_SET, 0, "hidefishingrod", NULL_KEY);
}

default
{
state_entry()
        {
        initialize();
        //For easy rotation in the llSitTarger enter the vector rotation below..
        vector eul = Angle; //45 degrees around the z-axis, in Euler form..
        eul *= DEG_TO_RAD; //convert to radians...
        rotation quat = llEuler2Rot( eul ); //convert to quaternion...
    //    llSay(0, LoadText);
        //Text it says under the context menu...
        llSetSitText(Context);
        //Adjust the positioning of the user while siting... also need for llAvatarOnSit... if this value is equal to 0, it doesn't work, so set it to make it look right for your object
        llSitTarget(SitLoc, quat);
        llMessageLinked(LINK_SET, 0, "showfishingrod", NULL_KEY);
        llMessageLinked(LINK_SET, 0, "hidefishingrod", NULL_KEY);
        }

changed(integer change)
{
        //If the user sits on the object...
        if (change & CHANGED_LINK)
        {
           
        user = llAvatarOnSitTarget();
            if (llAvatarOnSitTarget() != NULL_KEY )
            {
            llRequestPermissions(user, PERMISSION_TRIGGER_ANIMATION);
            llMessageLinked(LINK_SET, 0, "showfishingrod", NULL_KEY);
            llMessageLinked(LINK_SET, 0, "hidefishingrod", NULL_KEY);
            }
       
            else
            {
          //      llSay(0, "getting up");
            llStopAnimation(llGetInventoryName(INVENTORY_ANIMATION, 0));
            llMessageLinked(LINK_SET, 0, "showfishingrod", NULL_KEY);
            llMessageLinked(LINK_SET, 0, "hidefishingrod", NULL_KEY);
           
            }
        }
       
}
run_time_permissions(integer perm)
{
        if (perm)
        {
            //This starts the first animation...
             llStopAnimation("sit");
            llStartAnimation(llGetInventoryName(INVENTORY_ANIMATION, 0));
        curAnim = 0;
        }
}
}


Top
 Profile  
 
 Post subject: Re: Attach from contents
PostPosted: Mon May 14, 2012 3:41 pm 
Furious Typer
User avatar

Joined: Fri Aug 19, 2011 7:10 pm
Posts: 144
Location: Oldham, UK
I can see what you are thinking, but the fishing pose is animated, and the rod needs to follow the motion of the hands, hence needing to attach. I already have the anim playing on sit, so that's not a problem. At the moment I have a rod next to the seat that the user can grab (the rod itself consists of two prims, one a flexi for the line, so it's all a dynamic illusion when it's working together).

Whilst your solution would be fine for a static pose, it won't work for an animated one :(

_________________
50's sim based at Rumbled on OSGrid
happily running on Arch Linux for 1 year +


Top
 Profile  
 
 Post subject: Re: Attach from contents
PostPosted: Mon May 14, 2012 4:44 pm 
OSG Elite
User avatar

Joined: Thu Dec 11, 2008 7:51 am
Posts: 391
Location: England UK
Just a thought....

Could you not make the rod rez from the poseball/seat then use llAttachToAvatar in the rod?

Something along the lines of this:

- Avatar sits on prim
- Script in prim rezzes the rod (from prim inventory)
- Script in rod attaches to avatar

In theory it should work but needs testing to make sure the position of the rod is kept; I remember a bug(?) where an object rezzed from inventory to ground wouldn't remember its attachment point/position. I'm not sure if this still exists or not.

_________________
"...And then one day you'll find, ten years have got behind you, no one told you when to run, you missed the starting gun"
~Pink Floyd


Top
 Profile  
 
 Post subject: Re: Attach from contents
PostPosted: Mon May 14, 2012 6:39 pm 
Furious Typer
User avatar

Joined: Fri Aug 19, 2011 7:10 pm
Posts: 144
Location: Oldham, UK
Ahh - now that's a thought - never thought of rezzing then attaching - it could work - and llAttachToAvatar allows you to set the attach point explicitely, so wouldn't need to be remembered. A job for testing tomorrow :)

_________________
50's sim based at Rumbled on OSGrid
happily running on Arch Linux for 1 year +


Top
 Profile  
 
Display posts from previous:  Sort by  
Post a new topicPost a reply Page 1 of 1   [ 5 posts ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  


Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
610nm Style by Daniel St. Jules of Gamexe.net