Jump to content

secret door script modify


ceruleandepth
 Share

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

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

Recommended Posts

Hello everyone,

 

How can I make this script work for anyone, and not just the owner?

 

Thanks!

 

default
{ // Triggered when objects (including avatars) collide with the object containing this script
    collision_start(integer nd)
    {
        while(nd)
        { // Cycle through the detected keys of those objects that collided this time checking if each is the owner.
            if(llDetectedKey(--nd) == llGetOwner())
                llSetStatus(STATUS_PHANTOM, TRUE); // Become un-solid
        }
    }
    collision_end(integer nd)
    {
        if(llGetStatus(STATUS_PHANTOM)) // If the object is un-solid
            llSetStatus(STATUS_PHANTOM, FALSE); // Set the object solid.
    }
}
Link to comment
Share on other sites

  • Lindens

In other  words use this:

 

default{ // Triggered when objects (including avatars) collide with the object containing this script    collision_start(integer nd)    {        llSetStatus(STATUS_PHANTOM, TRUE); // Become un-solid    }    collision_end(integer nd)    {        if(llGetStatus(STATUS_PHANTOM)) // If the object is un-solid            llSetStatus(STATUS_PHANTOM, FALSE); // Set the object solid.    }}

 

 

  • Like 1
Link to comment
Share on other sites

I was wondering whether to just post the script as it should be but I was concerned that the purpose of the forum was to help people learn to script not rewrite the scripts for them.

The concern was (and has happened in the past) that folks post scripts or just ask and except the forum peeps to do all the work.

I get the good hearted intention Kelly but what do you think? I would like to stick to giving answers that allow the person to play with the script a bit and get the sense of accomplishment that comes from that. 

Disclosure: I couldn't write a script to save my life but I'm a very decent frankenscriptor. :smileywink:

Link to comment
Share on other sites

  • Lindens

In this case neither of the other posts explained why to make the changes they suggested, so I'm not sure how they are any better at teaching than just giving the fixed script - especially for a script of this small size.

So, in my opinion for something this size:


The reason it only works for the owner is because of the check that llDetectedKey == llGetOwner. Try this script:

<full script>


Is probably more teaching than:

 


Try removing these lines

<code snip>


 

Which is I think no more or less teaching than just:

 


Try this script

<full script>


In a large script it is possible that pointing out the specific line that needed changing would be more informative even without any explanation. But in this case it hardly seems to matter, and in either case the explanation would surely help.

 

Link to comment
Share on other sites

// Make an access list  to check against. Also note subtle difference of using --nd vrs nd--  in the argument.


// list of keys for access:
list listAccess = [
"a2e76fcd-9360-4f6d-a924-000000000003",  // guest Philip
"0e346d8b-4433-4d66-a6b0-fd37083abc4c"   // guest Kelly
];


default
{
    state_entry()
    {
        listAccess += llGetOwner(); // Owner is auto added at reset. No need to screen for later.
        llSetStatus(STATUS_PHANTOM, FALSE); // Set the object solid.
    }
    
    // Triggered when objects (including avatars) collide with the object containing this script
    collision_start(integer nd)
    {        
        while(nd)
        { // Cycle through the detected keys of those objects that collided this time checking if each is on the list.            
            if(llListFindList(listAccess, [(string)llDetectedKey(--nd)])  >= 0 )
                llSetStatus(STATUS_PHANTOM, TRUE); // Become un-solid
        }        
    }
    
    collision_end(integer nd)
    {
        if(llGetStatus(STATUS_PHANTOM)) // If the object is un-solid
                llSetStatus(STATUS_PHANTOM, FALSE); // Set the object solid.
    }
}

 

Link to comment
Share on other sites

I'm mostly just delighted that Kelly posted at all.

I have often wondered about this kind of construction:

 

 if(llGetStatus(STATUS_PHANTOM)) // If the object is un-solid            llSetStatus(STATUS_PHANTOM, FALSE); // Set the object solid.

 

Seems it would be just as efficient, or maybe more so, to just set phantom to false without bothering to check its current state at all. Is that true?

 

Link to comment
Share on other sites

 


PeterCanessa Oh wrote:


Paladin Pinion wrote:

I'm mostly just delighted that Kelly posted at all. 

QFT!  I'd even go for "I'm mostly just delighted that Kelly"

(exists, didn't get fired, posts, etc.) :smileyvery-happy:

 

 

lol, seconded

 

PS
welcome to the content fora Kelly, were we actually like Lindens... (most days =X)

Link to comment
Share on other sites

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