Jump to content

Temp attachment detaches when rezzer detaches - can't llDie or make disappear


YaniiMarie
 Share

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

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

Recommended Posts

Hey all

So I've been fiddling with a script in a bong that rezzes and attaches temporary lighter from its inventory using llRezObject, animates and all that jazz, and when I detach the bong, the lighter also detaches and requests perms again from its original rezzed position (which is in front of my face, for the time being). I've tried incorporating llDie at different parts of the script to coincide with the detachment and nothing.

If you need code posted, I can attach it, just didn't wanna make the post gross and clogged.

I've messed around with start parameters, from default to prim temp on rez, object temp on rez. I use llAttachToAvatarTemp inside the lighter. I have them say/listen to each other briefly to get the animations started. And I try to have the lighter check for the OBJECT_REZZER_KEY in the attachment list on a timer. A whole rigmarole of adjustments and changes that sometimes worked, sometimes broke it.

Any ideas on what might be causing that or if it's just normal behavior?

 

**Edit**

Lighter and bong scripts are in the second and third comments.

Edited by YaniiMarie
update to info in comments
Link to comment
Share on other sites

17 hours ago, Wulfie Reanimator said:

Go ahead and post the code for the lighter.

Here's the lighter code:

//All Listen-related types
integer channel = -525600; //chat channel for bong
key bongKey; //listen for bong in findBongName
key lightKey; //detect key for lighter, say to bong?

string message; //whatever key the bong sends over as a string
string lightName; //llGetObjectName()
string bongName; //actual bong attachment name


//integers
integer param;
integer perms;
integer attachLight = ATTACH_RHAND; //attach lighter
integer counter;


//misc
list find;
float time = 3.0;



///////custom events

findBongName()
{ 
        // Listen for messages on the shared channel, from only the rezzer.
        llListen(channel, "", bongKey, "");
        
}


bongCheck()
{
    key id = llGetOwner();
    list invo = llGetAttachedList(id);
    list bong = [OBJECT_REZZER_KEY];
   
    if(llListFindList(invo, bong))
    {
        ;
    }
    else
    {
        llDetachFromAvatar();
    }

}

///////main script


default
{
    state_entry()
    {
        llSay(0, "Hello, Avatar!");
        key id = llDetectedKey(0); //who's holding it
        key own = llGetOwner(); //who owns it
        lightName = llGetObjectName();
         //remove if it breaks//
       
        perms = PERMISSION_ATTACH;
        llListen(channel, "", bongKey, message);
    }

    on_rez(integer param)
    {
        key id = llGetOwner(); //who owns it
        list find = llGetAttachedList(id);
        key bongKey = (string)OBJECT_REZZER_KEY;

        if(llListFindList(find,[OBJECT_REZZER_KEY]))
        {
            llRequestPermissions(id,perms);
        }
        else
        {
            llDetachFromAvatar();
        }
        
    }
    
    
    run_time_permissions(integer perms)
    {
        key id = llGetOwner();
        
        if(id)
        {
            if(perms == perms)
            {
                llAttachToAvatarTemp(attachLight);
            }
        }
        else if(!llGetAttached())
        {
            llDetachFromAvatar();
            llDie();
        }
        
    }
    
    
    attach(key id)
    {
        lightKey = llGetKey(); 
        
        llRequestPermissions(id, perms);
        llSay(channel, "Spark up"); 
        llSetTimerEvent(time);
        
        if(llGetAttached())
        {
            findBongName(); //listen for bongkey
        }
        else if(id == NULL_KEY)
        {
            llDie();
        }
        
    }
        
    //OBJECT_REZZER_KEY need to use somewhere, don't forget
    listen(integer channel, string name, key id, string message)
    {
        find = llGetAttachedList(id);
       // Get the key of the object which rezzed this object.
        list details = llGetObjectDetails(llGetKey(), [OBJECT_REZZER_KEY]);
        
        bongKey = llList2Key(details, 0);
     
        ///
        
        if(id == bongKey)
        {
            bongName = llKey2Name(bongKey);
            
            if((counter >= 6) && llListFindList(find, [OBJECT_REZZER_KEY]))
            {
                counter = 0;
                llSetTimerEvent(time);
            }
            else if(message == "Detached")
            {
                llDetachFromAvatar();
            }           
        }
        else if(channel && (name == bongName))
        {
            if(message == "Detached")
            {
                llDetachFromAvatar();
            }
        }
        
    }
    
    timer()
    {
        counter++;
        
        if(counter >= 6)
        {
            bongCheck();
            counter = 0;
            llSetTimerEvent(time);
        }
        
        if(counter == 2)
        {
            bongCheck();
        }
        
        if(counter == 2)
        {
            bongCheck();
        }
        
    }
            
               

}

 

Link to comment
Share on other sites

And the bong script for anyone interested:

 

//Regular animation script
//Animate on attach
//Add lighter temp attachment from bong inventory

integer channel = 525600;
string msg;
string detect = "Still here";
string detach = "Bye, bye!";


//Animation names
string idle = "LoopTest2";
string hit = "HitBong2";

float time = 3.0;
integer counter;

key id;
string lighter;

integer attach_point = ATTACH_LHAND;
integer perms;

//Animation functions
idleHold()
{
    llStartAnimation(idle);    
}

bongHit()
{
    llStartAnimation(hit);
}

///////

default
{
    state_entry()
    {
        id = llGetOwner();
        //Temp lighter
        lighter = llGetInventoryName(INVENTORY_OBJECT,0);
        perms = PERMISSION_TRIGGER_ANIMATION | PERMISSION_OVERRIDE_ANIMATIONS;
    llRequestPermissions(id, perms);
    llListen(channel, lighter, "", "");
    }

    on_rez(integer attach_point)
    {
        id = llGetOwner();
        if(id)
        {
            llRequestPermissions(id, perms);
                
        }
        else
        {
            llResetScript();
        }
        
        
    }
        
    
    run_time_permissions(integer perms)
    {
        if(!perms)
        {
            llRequestPermissions(id, perms);
        }
        else
        {
            llSetTimerEvent(3.0);
        }
    }
        
    
    attach(key id)
    {
        id = llGetOwner();
        vector position = llGetPos() + <0,0,1>;
         
        if(llGetAttached())
        {
          llRezObject(lighter, position, ZERO_VECTOR, ZERO_ROTATION, OBJECT_TEMP_ON_REZ);
           llStartAnimation(idle);
        }
        else
        {
            llSay(channel, "Detached");
        }
    } 
        
        
    object_rez(key obj)
    {
        obj = (key)lighter; //save lighter key, wait for listen event        
    }
    
    listen(integer channel, string name, key id, string message)
    {
        if(id == (key)lighter && message == "Spark up");
        {
            llSetTimerEvent(time);
        }
    }

    
    timer()
    {
        counter++;
        
        if(counter >= 10)
        {
            counter = 0;
            llSetTimerEvent(time);
        }
        
        if(counter == 8)
        {
            bongHit();
        }
        
        if(counter == 6)
        {
            idleHold();
        }
        
        if(counter == 2)
        {
            bongHit();
        }
        
        if(counter == 0)
        {
            idleHold();
        }
    }
    
    changed(integer mask)
    {   //Triggered when the object containing this script changes owner.
        if(mask & CHANGED_OWNER)
        {
            llResetScript();   // This will ensure the script listens to the new owner, and doesn't continue listening to the creator.
        }
    }


}

 

Link to comment
Share on other sites

In the lighter script findBongName:

llListen(channel,””,bongKey,””) needs a valid value in bongKey but it is not set

your attempt to set it in on_rez is not correct, try

bongKey = llList2Key(llGetObjectDetails(llGetKey(),[OBJECT__REZZER_KEY]),0);

dont make bongKey a local variable by prepending it with “key “

Good luck!

Link to comment
Share on other sites

16 hours ago, Marvin Benelli said:

In bong script attach event:

if(id==NULL_KEY){

       llSay(channel, "Detached");
}

Smh, I always forget about using "==". I'd done this bit before, but only "=". I'll give this a shot.

 

15 hours ago, Marvin Benelli said:

In the lighter script findBongName:

llListen(channel,””,bongKey,””) needs a valid value in bongKey but it is not set

your attempt to set it in on_rez is not correct, try

bongKey = llList2Key(llGetObjectDetails(llGetKey(),[OBJECT__REZZER_KEY]),0);

dont make bongKey a local variable by prepending it with “key “

Good luck!

Thank you for this. I'm always botching my variables, gotta remember to keep the ones within the function more general so I'm not making the script all screwy. I'll give this a shot, too, and let ya know how it goes. This was my attempt at piecing various parts of the wiki and other thread answers together lol

Link to comment
Share on other sites

On 2/15/2024 at 8:47 PM, Marvin Benelli said:

You’re well on your way, but keep me posted 

Okay, so completely moved a bunch of stuff around after your fixes didn't work 🙃 I wish there was a way to post the code shorter or in a spoiler. But I'll drop the new bong script and lighter script here. Now the lighter disappears but way too soon lol. I know it has something to do with whatever's happening with my attach event or maybe the bongCheck() but I just can't nail it. (Also might have some unnecessary/unused integers and strings sitting at the beginning that I need to nix, I'll get around to it lol)

>> Bong Script:

Quote

 

//Regular animation script
//Animate on attach
//Add lighter temp attachment from bong inventory

integer channel = 525600;
string msg;
string detect = "Still here";
string detach = "Detached";


//Animation names
string idle = "LoopTest2";
string hit = "HitAnim9b";

float time = 3.0;
integer counter;

key id;
string lighter;

integer attach_point = ATTACH_LHAND;
integer perms;

//Animation functions
idleHold()
{
    llStartAnimation(idle);    
}

bongHit()
{
    llStartAnimation(hit);
}

///////

default
{
    state_entry()
    {
        id = llGetOwner();
        //Temp lighter
        lighter = llGetInventoryName(INVENTORY_OBJECT,0);
        perms = PERMISSION_TRIGGER_ANIMATION | PERMISSION_OVERRIDE_ANIMATIONS;
    llRequestPermissions(id, perms);
    llSay(0, "Hi, I'm Paul!");
    llListen(channel, lighter, "", "");
    }

    on_rez(integer attach_point)
    {
        id = llGetOwner();
        
        if(id)
        {
            if(llGetAttached()==ATTACH_LHAND)
            {
                llRequestPermissions(id, perms);
                
            }
            else
            {
                llResetScript();
            }
        }
        
    }
        
    
    run_time_permissions(integer perms)
    {
        if(!perms)
        {
            llRequestPermissions(id, perms);
        }
        else
        {
            llSetTimerEvent(1.25);//4count is full hit animation
        }
    }
        
    
    attach(key id)
    {
        id = llGetOwner();
        vector position = llGetPos() + <0,0,1>;
        
        if(id==NULL_KEY && llGetAttached()==0)
        {
            llSay(channel, "Detached");
            llSay(0, "Detached");
            llResetScript();
        } 
        else if(llGetAttached()==ATTACH_LHAND)
        {
          llRezObject(lighter, position, ZERO_VECTOR, ZERO_ROTATION, OBJECT_TEMP_ON_REZ);
           llStartAnimation(idle);
        }
        
    } 
        
        
    object_rez(key obj)
    {
        obj = (key)lighter; //save lighter key, wait for listen event        
    }
  
    
    listen(integer channel, string name, key id, string message)
    {
        if(id == (key)lighter && message == "Spark up");
        {
            llSetTimerEvent(time);
        }
    }

    
    timer()
    {
        counter++;
        
        if(counter >= 10)
        {
            counter = 0;
            llSetTimerEvent(time);
        }
        
        if(counter == 8)
        {
            bongHit();
        }
        
        if(counter == 6)
        {
            idleHold();
        }
        
        if(counter == 2)
        {
            bongHit();
        }
        
        if(counter == 0)
        {
            idleHold();
        }
    }
    
    changed(integer mask)
    {   //Triggered when the object containing this script changes owner.
        if(mask & CHANGED_OWNER)
        {
            llResetScript();   // This will ensure the script listens to the new owner, and doesn't continue listening to the creator.
        }
    }


}

 

>> Lighter Script:

Quote

 

//All Listen-related types
integer channel = -525600; //chat channel for bong
key bongKey; //listen for bong in findBongName
key lightKey; //detect key for lighter, say to bong?

string message; //whatever key the bong sends over as a string
string lightName; //llGetObjectName()
string bongName; //actual bong attachment name


//integers
integer param;
integer perms;
integer attachLight = ATTACH_RHAND; //attach lighter
integer counter;


//misc
list find;
float time = 3.0;



///////custom events

findBongName()
{ 
        // Listen for messages on the shared channel, from only the rezzer.
        llListen(channel, "", bongKey, "");
        
}


bongCheck()
{
    
    key id = (string)llGetObjectName(); //lighter name
    key bongkey;
    list find = llGetAttachedList(llGetOwner());
    list details = llGetObjectDetails(id,[OBJECT_REZZER_KEY]);
    
    integer rezzer = llList2Integer(details, OBJECT_REZZER_KEY); //becomes bongKey
    
    if(id!=NULL_KEY)
    {
        bongKey = (string)OBJECT_REZZER_KEY;
    }
    
    integer bong = llListFindList(find,[bongKey]); //detects bong as attachment

    if(bong == -1)
    {
        llDetachFromAvatar();
    }


    llListen(channel, "", bongKey, "Detached");
    

}

///////main script


default
{
    state_entry()
    {
        
        llSay(0, "Hello, Avatar!");
        key id = llDetectedKey(0); //who's holding it
        key own = llGetOwner(); //who owns it
        lightName = llGetObjectName();
         //remove if it breaks//
       
        perms = PERMISSION_ATTACH;
        bongCheck();
    }

    on_rez(integer param)
    {
        key id = llGetOwner(); //who owns it
        list find = llGetAttachedList(id);
        
        llResetTime();
//        bongKey = llList2Key(llGetObjectDetails(llGetKey(),[OBJECT_REZZER_KEY]),0);

        if(llListFindList(find,[OBJECT_REZZER_KEY]))
        {
            llRequestPermissions(id,perms);
        }
        else 
        {
            llDie();
        }
        
    }
    
    
    run_time_permissions(integer perms)
    {
        key id = llGetOwner();
        
        if(id)
        {
            if(perms == perms)
            {
                llAttachToAvatarTemp(attachLight);
            }
        }
        else if(id == NULL_KEY)
        {
           if(llGetTime() < 3.0) 
           {
               llRequestPermissions(id,perms);
            }
            else if(llGetTime() >= 10.0)
            {
                llDie();
            }
        }
        
    }
    
    
    attach(key id)
    {
        llSay(channel, "Spark up"); 
        llSetTimerEvent(time);
        integer findBong = llListFindList(llGetAttachedList(id), [OBJECT_REZZER_KEY]);
        
        if(llGetAttached()!=0 && findBong!=-1)
        {
            llRequestPermissions(id, perms);
            bongCheck();
        }
        else if(perms & id == NULL_KEY)
        {
            if(findBong == -1)
            {
                if(llGetTime() > 5.0)
                {
                    llDetachFromAvatar();
                    llDie();
                }
            }
        }
        
        
    }
        
   
    listen(integer channel, string name, key id, string message)
    {
        key bongKey;
        find = llGetAttachedList(id);
       // Get the key of the object which rezzed this object.
//        list details = llGetObjectDetails(llGetKey(), [OBJECT_REZZER_KEY]);
        
//        bongKey = llList2Key(details, 0);
     
        ///
        //outcome of bongCheck event
        if(id == bongKey)
        {
            bongName = llKey2Name(bongKey);
            if(message == "Detached")
            {
                llDetachFromAvatar();
            }          
        }
        else if(channel==0 && message == "Detached")
        {
            llDetachFromAvatar();
        }
        else if((counter >= 6) && llListFindList(find, [OBJECT_REZZER_KEY]))
            {
                counter = 0;
                llSetTimerEvent(time);
            } 
        
    }
    
    timer()
    {
        counter++;
        
        if(counter == 6)
        {
            bongCheck();
        }
        
        if(counter == 5)
        {
            bongCheck();
        }
        
        if(counter == 3)
        {
            bongCheck();
        }
        
        if(counter == 1)
        {
            bongCheck();
        }
        
    }
            
               

}

 

 

Edited by YaniiMarie
Link to comment
Share on other sites

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