Jump to content

llSame Group Needs to be added...how?


OddbroShillings
 Share

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

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

Recommended Posts

Ok, in the basic curtain script below, I would like it to be group access only. I tried the llSameGroup, but i think i left something out and probaly placed it in the wrong spot. If anyone can simply show me where to place it or show me what needs to be added it would be greatly appreciated. Thank you in advance.

vector offset = <1,0,0>; //Prim moves/changes size along this local coordinate
float hi_end_fixed = FALSE; //Which end of the prim should remain in place when size changes?          
                            //The one with the higher (local) coordinate? 
float min = 0.2; //The minimum size of the prim relative to its maximum size
integer ns = 15; //Number of distinct steps for move/size change
 
 
default {
    
    state_entry() {
        offset *= ((1.0 - min) / ns) * (offset * llGetScale());
        hi_end_fixed -= 0.5;
    }
 
    touch_start(integer detected) {
        integer i;
        do  llSetPrimitiveParams([PRIM_SIZE, llGetScale() - offset,
                PRIM_POSITION, llGetLocalPos() + ((hi_end_fixed * offset) * llGetLocalRot())]);
        while ((++i) < ns);           
        offset = - offset;
    }
}

 

Link to comment
Share on other sites

vector offset = <1,0,0>; //Prim moves/changes size along this local coordinatefloat hi_end_fixed = FALSE; //Which end of the prim should remain in place when size changes?                                      //The one with the higher (local) coordinate? float min = 0.2; //The minimum size of the prim relative to its maximum sizeinteger ns = 15; //Number of distinct steps for move/size change  default {        state_entry() {        offset *= ((1.0 - min) / ns) * (offset * llGetScale());        hi_end_fixed -= 0.5;    }     touch_start(integer detected) {        if (llSameGroup(llDetectedKey(0))) {

integer i; do llSetPrimitiveParams([PRIM_SIZE, llGetScale() - offset, PRIM_POSITION, llGetLocalPos() + ((hi_end_fixed * offset) * llGetLocalRot())]); while ((++i) < ns); offset = - offset;

}

}}

 That should work.  When someone touches the object, it will first determine if they currently have the same group active.

Link to comment
Share on other sites

note that if multiple people are touching it, that only checks that the first one is in the group, and processes any others regardless... if you are going to handle multiple touchers at once (which is what the loop does) then you need to put the if stament inside of the loop around the action to take, and test each index, and not just the first one (0)

Link to comment
Share on other sites

The curtains won't open unless it's someone in the group that touches the object.  True, if someone NOT in the group touches it a slight fraction of a second before someone IN the group touches it, the loop will not run and the curtains will not open.  It discards anyone other than the first person who touches it. For a non mission critical application, the way I wrote it is sufficient I think.

However, if you want to check each person touching during the same script cycle use:

 

vector offset = <1,0,0>; //Prim moves/changes size along this local coordinatefloat hi_end_fixed = FALSE; //Which end of the prim should remain in place when size changes?                                      //The one with the higher (local) coordinate? float min = 0.2; //The minimum size of the prim relative to its maximum sizeinteger ns = 15; //Number of distinct steps for move/size change  default {        state_entry() {        offset *= ((1.0 - min) / ns) * (offset * llGetScale());        hi_end_fixed -= 0.5;    }     touch_start(integer detected) {
integer x;
for (x=0;x<detected;x++) {
if (llSameGroup(llDetectedKey(x))) { integer i; do llSetPrimitiveParams([PRIM_SIZE, llGetScale() - offset, PRIM_POSITION, llGetLocalPos() + ((hi_end_fixed * offset) * llGetLocalRot())]); while ((++i) < ns); offset = - offset;
} }
}
}

 This script adds the addition of running through the group check for each person that touched the object during the script cycle.  Now you may run into the issue of two people touching during the same script cycle, both in the group, and have the curtains open then shut.

Link to comment
Share on other sites

With a two-state object like a curtain, checking all the touchers will result in a quick state flip if the number of allowed touchers is even. The script will open the curtain for one allowed toucher and close it for the next one, or vice-versa, and so on. It will produce the right result only if the number of allowed touchers is odd... plus some flipping before to reach this result.

It would be more appropriate to react only to the first allowed toucher.

 

touch_start(integer num) 
{
    for (--num; num >= 0; --num)
    {
        if (llSameGroup(llDetectedKey(num)))
        {
            integer i = ns;
            for (; i > 0; --i)
            {
                llSetPrimitiveParams([PRIM_SIZE, llGetScale() - offset,
                PRIM_POSITION, llGetLocalPos() + ((hi_end_fixed * offset) * llGetLocalRot())]);
            }          
            offset = - offset;
            return; // Stop after first allowed toucher is found.
        }
    }
}


 

That will do it.

 

Link to comment
Share on other sites

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