Jump to content

adding owner only to curtains


Janford Flax
 Share

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

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

Recommended Posts

My abilities are limited to modifying existing scripts and I've had some good luck so far.  But I cannot figure out how to make this script work only for the owner.  It's the curtain script that I found on the old forums.  I read through a lot of forum stuff and found that  if(llDetectedKey(0)==llGetOwner()) after the touchstart code does indeed restrict using the curtains to the owner.  

However, when someone else touches the curtains the state_entry seems to be triggered so when I come back later to the curtains in the open position, where I left them, they open again, which is going the wrong direction and I end up with a little sliver of a prim.

My goal is for only me to be able to operate the curtains.  Any assistance is greatly appreciated! 

 

//When touched the prim is retracted towards one end and when touched again stretched back out.
//
//Prim moves/changes size along the local coordinate specified in the offset vector below.
//
//To change the overall size, edit the prim when stretched out and reset the script when done. 
//
//The script works both in unlinked and linked prims.
//
// Copyright (C) 2008 Zilla Larsson
//    This program is free software: you can redistribute it and/or modify
//    it under the terms of the GNU General Public License version 3, as 
//    published by the Free Software Foundation.
//
//    This program is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU General Public License for more details.
//
//   You should have received a copy of the GNU General Public License
//    along with this program.  If not, see <http://www.gnu.org/licenses/>


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.15; //The minimum size of the prim relative to its maximum size
integer ns = 10; //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

The only way that the stuff in state_entry will ever be read again is if you re-enter state default, and that won't happen in this little script unless you reset the script for some reason.  It's only setting the values of those two constants anyway.  So don't reset the script.  If you want to add your if statement to restrict acess, just be sure that your {curly brackets} encompass everything in the touch_start event.

touch_start(integer detected) {    if (llGetOwner() == llDetectedKey(0)){        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

Many thanks!

Unfortuanately, the script needs to be reset when you change the size of the prim.  So when I resize the curtains I have to reset the script.  Maybe I can make sure the prim is the correct size before I put the script in.  Not as elegant but might work.

Thank you so much for you help.

Link to comment
Share on other sites

I don;t see why that's necessary.  After all, the whole purpose of the script is to change the prim's size and then reverse the change.  You shouldn't have to reset the script unless you need to change the prim's starting size, as you might if you were about to install it in a bigger window, for example.  In any case, resetting the script will make it forget whatever its previous size was, so that's definitely not what you want to do in normal operation.

Link to comment
Share on other sites

  • 3 weeks later...

Can I impose on you again and ask how I can make this poseball script owner-only?  

 

// Basic pose ball script. by Dora Gustafson, Studio Dora 2010// Free for anybody to read, copy, modify, compile, use, rip apart, trample on and flush// v1.3 with Set Click Actionstring animation = "stand"; // name of built-in animation or animation in prim inventorydefault{    state_entry()    {        llSitTarget( <0.0, 0.0, 0.01>, ZERO_ROTATION );        llSetSitText(llToUpper(animation));        llSetClickAction(CLICK_ACTION_SIT);    }    changed(integer change)    {        if (change & CHANGED_LINK)        {            key sitter = llAvatarOnSitTarget();            if(sitter != NULL_KEY) llRequestPermissions(sitter , PERMISSION_TRIGGER_ANIMATION);            else            {                if (llGetPermissions() & PERMISSION_TRIGGER_ANIMATION) llStopAnimation(animation);                llSetAlpha(1.0, ALL_SIDES); // show prim            }        }    }    run_time_permissions(integer perm)    {        if ( perm & PERMISSION_TRIGGER_ANIMATION )        {            llSetAlpha(0.0, ALL_SIDES); // hide prim            llStartAnimation(animation);            llStopAnimation("sit");        }    }}
Link to comment
Share on other sites

The same way you did with the other script.  The only difference is that you don't have llDetectedKey(0).  You have llAvatarOnSitTarget(). So modify the changed event the same way you modified the touch_start event in the other script. Or, even quicker, swap sitter == llGetOwner() for sitter != NULL_KEY  :smileywink:

Link to comment
Share on other sites

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