Jump to content

Temp Attach


Marrelda
 Share

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

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

Recommended Posts

Hello, I was wondering if anyone could help me with a scripting query please.

 

I have the following script that allows for an object to temporarily transfer to another avatar (not the object owner). When they touch the object, it requests permission to attach, and then when permission is granted, it attaches to them without appearing in their inventory. The script is:

 

default
{
    touch_start(integer num_touches)
    {
        llRequestPermissions( llDetectedKey(0), PERMISSION_ATTACH );
    }
 
    run_time_permissions( integer vBitPermissions )
    {
        if( vBitPermissions & PERMISSION_ATTACH )
        {
            llAttachToAvatarTemp( ATTACH_HUD_CENTER_1 );
        }
        else
        {
            llOwnerSay( "Permission to attach denied" );
        }
    }
 
    on_rez(integer rez)
    {
        if(!llGetAttached())
        { //reset the script if it's not attached.
            llResetScript();
        }
    }
}

 

Now what I'm wondering, is rather than attaching the object it is inside, is it possible to change this script so it temorarily attaches an item within the contents of the object. To try and clarify incase I am not making sense (its early and I am so far without coffee...) If I have a prim, for arguments sake, a sign, at the moment the script is attaching the sign to the AV that clicks it. Can I / how would I change this so that clicking the sign actually attaches a HUD that is in the signs contents?

 

Any assistance or advice / explanation you can give would be greatly appreciated... I'm trying to learn a bit more about scripting and this one has me scratching my head.

Link to comment
Share on other sites

I'm thinking two scripts.  One in an object-giver that contains the temp-attachment.  The other in the temp-attachment.

 

  1. On touch the object-giver will rez the temp-attachment
  2. Object-giver sends message to new temp-attachment with UUID of toucher.
  3. New temp-attachment requests permission to attach from the toucher.
  4. If permission received temp-attachment attaches temporary - otherwise kills itself after a set time expires.
  • Like 1
Link to comment
Share on other sites

Ok,

I have it so it is rezzing the HUD with this script:

 

default
{
     touch_start(integer param)
     {
          llRezObject("HUD", llGetPos() + <0.0,0.0,1.0>, <0.0,0.0,0.0>, <0.0,0.0,0.0,1.0>, 0);
     }
}

 

And have added this script to the HUD:

 

integer handle;
default
{
    listen(integer channel, string name, key id, string msg)
    {
        
        llRequestPermissions( (key)msg, PERMISSION_ATTACH );
    }
 
    run_time_permissions( integer vBitPermissions )
    {
        if( vBitPermissions & PERMISSION_ATTACH )
        {
            llAttachToAvatarTemp(ATTACH_HUD_CENTER_1);
             llSetTimerEvent(0);
            llListenRemove(handle);
        }
        else
        {
            llWhisper(0, "Permission to attach denied - click the stone again if you want a new try" );
           llDie();
        }
    }
 
    on_rez(integer rez)
    {
        if(!llGetAttached())
        { //reset the script if it's not attached.
            llResetScript();
        }
    }
    state_entry()
    {
        
        handle=llListen(-1,"",NULL_KEY,"");
        llSay(-1,"who");
        // llSay(0,"who");
        llSetTimerEvent(30);
        
    }
    timer()
    {
        llWhisper(0, "Permission to attach denied - click the stone again if you want a new try" );
        llDie();
    }
}

 

But Its not asking for permission to rattach when it rezzes.... any idea where ive gone wrong?

Link to comment
Share on other sites

Thank you :) - the question was directed towards anyone willing to answer!

 

I knew it would be something obvious.... im guessing something like :

        handle=llListen(-1,"",NULL_KEY,"who");
        avatar2=llDetectedKey(0);

 

I'll have a play and see if i can make it work. Scripting is still a relatively new thing for me so I'll no doubt make a mistake somewhere

Link to comment
Share on other sites

The problem to solve is how to tell the rezzed object who touched the rezzer.    

The rezzer knows who touched it -- llDetectedKey(0).   That's meaningless to the HUD.

So, after it's rezzed the object, it needs to communicate that information to the rezzed HUD.    One way to do that is, as you suggest, in chat.    The HUD will receive that information in the listen event, when it can act accordingly.

Link to comment
Share on other sites

Right.  So one good way to set up the communication is to pass the HUD a channel number on rez.  Use the object_rez event in your rezzer to wait a half second for the HUD to materialize and open that channel to listen and then send a llRegionSayTo message to the new HUD, telling it the UUID of the person it's supposed to attach to.

Link to comment
Share on other sites

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