Scripts Library

Creating scripts
User avatar
Constance Peregrine
Posts: 2348
Joined: Sun Dec 23, 2012 11:35 am
Has thanked: 2778 times
Been thanked: 1479 times

Scripts Library

Post by Constance Peregrine »

https://plus.google.com/+FredBeckhusen/ ... aKDnW68u69

Interesting scripting tho I have no clues what he is saying-)) (ok, some clues)
Laissez faire et laissez passer, le monde va de lui même!
My little sounds store https://www.kitely.com/market?store=2040306

Ephemeral wanderer...
User avatar
Ghaelen DLareh
Posts: 76
Joined: Thu Dec 27, 2012 4:13 pm
Has thanked: 49 times
Been thanked: 59 times
Contact:

Linked Swing Door

Post by Ghaelen DLareh »

I don't remember where I got this script, but it works great. Put the script in the door and link the door to the building. The building needs to be the root prim.

Code: Select all

/*John Duke offset door hinge (c) 2016 for SL and OS
 * Define the rotation in degrees, using the door prim's local coordinate
 * system
 */
vector      ROTATION            = <0.0,0.0,90.0>;
 
/*
 * Define the position of the virtual hinge; usually this is half the door
 * prim's width and thickness
 */
vector      HINGE_POSITION      = <0.97,-0.28,0.0>;
 
/*
 * Define how fast the door opens, in seconds
 */
float       SECONDS_TO_ROTATE   = 2.0;
 
/*
 * Define after how much time the door should close automatically, in seconds;
 * set to 0.0 to disable autolmatic closing
 */
float       AUTO_CLOSE_TIME     = 05.0;
 
/*
 * Define a sound that plays when the door starts to open; set to NULL_KEY
 * for no sound.
 */
key         SOUND_ON_OPEN       = "";
 
/*
 * Define a sound that plays when the door has closed; set to NULL_KEY
 * for no sound.
 */
key         SOUND_ON_CLOSE      = "";
 
/*
 * Define the volume of the opening and closing sounds
 */
float       SOUND_VOLUME        = 0.8;
 
/*
 * NORMALLY, THERE IS NO NEED TO CHANGE ANYTHING BELOW THIS COMMENT. IF YOU DO
 * YOU RISK BREAKING IT.
 */
 
integer     gClosed;            // Door state: TRUE = closed, FALSE = opened
rotation    gRotationClosed;    // Initial rotation of the door (closed)
vector      gPositionClosed;    // Initial position of the door (closed)
vector      gRotationPerSecond; // The amount to rotate each second
 
doOpenOrClose() {
    /*
     * Only perform the rotation if the door isn't root or unlinked
     */
    integer linkNumber = llGetLinkNumber();
    if (linkNumber < 2)
        return;
 
    if (gClosed) {
        /*
         * Store the initial rotation and position so we can return to it.
         *
         * Rotating back purely by calculations can in the longer term cause the door
         * to be positioned incorrectly because of precision errors
         *
         * We determine this everytime before the door is being opened in case it was
         * moved, assuming the door was closed whilst being manipulated.
         */
        gPositionClosed = llGetLocalPos();
        gRotationClosed = llGetLocalRot();
 
        /*
         * Play the opening sound and preload the closing sound
         */
        if (SOUND_ON_OPEN)
            llPlaySound(SOUND_ON_OPEN, SOUND_VOLUME);
    }
 
    vector hingePosition = gPositionClosed + HINGE_POSITION * gRotationClosed;
 
    /*
     * Reset the timer and start moving
     */
    llResetTime();
    while (llGetTime() < SECONDS_TO_ROTATE) {
        float time = llGetTime();
        if (! gClosed)
            /*
             * Invert the timer for closing direction
             */
            time = SECONDS_TO_ROTATE - time;
 
        rotation rotationThisStep = llEuler2Rot(gRotationPerSecond * time) * gRotationClosed;
        vector positionThisStep = hingePosition - HINGE_POSITION * rotationThisStep;
        llSetLinkPrimitiveParamsFast(linkNumber, [PRIM_ROT_LOCAL, rotationThisStep, PRIM_POS_LOCAL, positionThisStep]);
    }
 
    /*
     * Set the new state
     */
    gClosed = !gClosed;
 
    if (gClosed) {
        /*
         * Finalize the closing movement
         */
        llSetLinkPrimitiveParamsFast(linkNumber, [PRIM_ROT_LOCAL, gRotationClosed, PRIM_POS_LOCAL, gPositionClosed]);
 
        /*
         * Play the closing sound and preload the opening sound
         */
        if (SOUND_ON_CLOSE)
            llPlaySound(SOUND_ON_CLOSE, SOUND_VOLUME);
        if (SOUND_ON_OPEN)
            llPreloadSound(SOUND_ON_OPEN);
    } else {
        /*
         * Finalize the opening movement
         */
        rotation rotationOpened = llEuler2Rot(ROTATION * DEG_TO_RAD) * gRotationClosed;
        vector positionOpened = hingePosition - HINGE_POSITION * rotationOpened;
        llSetLinkPrimitiveParamsFast(linkNumber, [PRIM_ROT_LOCAL, rotationOpened, PRIM_POS_LOCAL, positionOpened]);
 
        /*
         * Preload the closing sound
         */
        if (SOUND_ON_CLOSE)
            llPreloadSound(SOUND_ON_CLOSE);
 
        /*
         * Set a timer to automatically close
         */
        llSetTimerEvent(AUTO_CLOSE_TIME);
    }
}
 
default {
    state_entry() {
        /*
         * Assume the door is closed when the script is reset
         */
        gClosed = TRUE;
 
        /*
         * These doesn't change unless the script is changed, calculate them once
         */
        gRotationPerSecond = (ROTATION * DEG_TO_RAD / SECONDS_TO_ROTATE);
 
        /*
         * Preload the opening sound
         */
        if (SOUND_ON_OPEN)
            llPreloadSound(SOUND_ON_OPEN);
    }
    touch_start(integer agentCount) {
        doOpenOrClose();
    }
    timer() {
        llSetTimerEvent(0.0);
 
           /*
         * Preload the close sound
         */
        if (SOUND_ON_CLOSE)
            llPreloadSound(SOUND_ON_CLOSE);
 
        /*
         * Close the door if it isn't already closed
         */
         
            
        if (! gClosed)
            doOpenOrClose();
        }
    }
The fussy bits are in figuring out what 1/2 the width and 1/2 the depth of the door should be in this line:

Code: Select all

vector      HINGE_POSITION      = <0.5,0.0,0.0>;
I found that simply dividing the sizes in half didn't make the door rotate as if on a hinge. For a 1.6m wide door, the x position had to be .97, and the y position was -0.28 for a .5 depth. Once I configured it that way it worked beautifully. The building can be moved and rotated, and the door still works. Re-sizing is another matter, of course, because the re-sized door needs the script HINGE_POSITION adjusted again.

EDIT: Duh.... if the mesh door has a handle on both sides, the depth of the physics is wider than the visible solid door. /slapforehead

So 1/2 the door width/depth works in a prim door. I'll leave up my erroneous conclusion in case it might benefit someone else who is using mesh doors with handles.
A Curative Poison (a metaverse story)

De Landria Rising Market

The De Landria Project
Don Smith
Posts: 34
Joined: Fri Jun 03, 2016 6:13 pm
Has thanked: 152 times
Been thanked: 41 times

Re: Scripts Library

Post by Don Smith »

Hi, New guy here, does anyone have a build rezzing script system? So i can put my homes i intend to build in them and rez a box, click to rez the build from? < i forgot what its called specifically > Or where can i find one? Ty.

UPDATE: as suggested by Anglecat Wingtips. via in game, i opened up a home from a rez box with full perm that works and got the scripts. Made a test rezzing box and some test objects, It works except, my 3 test objects all rez in the same spot. I've tried ressetting the scripts at various stages of the testing and still same results. Does anyone know what to suggest to get this thing to work, I will gladly share it freely amongst kitely builders if we can get it working!
Graham Mills
Posts: 1314
Joined: Sun Dec 23, 2012 2:26 pm
Has thanked: 1134 times
Been thanked: 1141 times

Re: Scripts Library

Post by Graham Mills »

Not something I do often but I think some people use Builders Buddy.

search.php?keywords=buddy
These users thanked the author Graham Mills for the post (total 2):
Don SmithChris Namaste
User avatar
Dot Matrix
Posts: 1625
Joined: Sun Jul 28, 2013 3:26 am
Has thanked: 1208 times
Been thanked: 2324 times

Re: Scripts Library

Post by Dot Matrix »

Brayla Sana includes a free builder's buddy script among others on her world:

https://www.kitely.com/virtual-world/Br ... na-Gallery

It's one she uses herself for her Kitely Market buildings.
These users thanked the author Dot Matrix for the post (total 3):
Ilan TochnerDon SmithSelby Evans
Don Smith
Posts: 34
Joined: Fri Jun 03, 2016 6:13 pm
Has thanked: 152 times
Been thanked: 41 times

Re: Scripts Library

Post by Don Smith »

Thanks so much for the replies! I just went and got one, and will test it shortly. Seeing that its used here is reassuring! Will update after i comfirm its a working script.


Hello again. After 2 more hours of trying, i still cant get this script to work. I would greatly appreciate if some of you would go and get a copy of it and see if you can get it to work and post here your results. Hopefully we can figure this out and get one working. Thanks again for your time and input.


///// UPDATE /////
Problem Solved! You must be the Owner of the land you use this builder buddy on or it wont work. Even in sandboxes, unless its your own.

Many Thanks to all who assisted with help and Info!
These users thanked the author Don Smith for the post (total 3):
Serene JewellDot MatrixSelby Evans
User avatar
Serene Jewell
Posts: 336
Joined: Thu Dec 27, 2012 6:12 am
Has thanked: 636 times
Been thanked: 397 times

Re: Scripts Library

Post by Serene Jewell »

Giz Ihnen recently found a nice collection of scripts. "It's in french. It has OS/SL scripts for all sorts of games. have only tried the maze generator so far and it worked perfect..."

http://digigrids.free.fr/wiki/index.php ... mples/Jeux
These users thanked the author Serene Jewell for the post:
Chris Namaste
User avatar
Freda Frostbite
Posts: 742
Joined: Sat Mar 29, 2014 2:10 am
Location: Florida, space coast.
Has thanked: 608 times
Been thanked: 769 times

Re: Scripts Library

Post by Freda Frostbite »

Anyone have a script for hypergates that actually works? NONE of the gates I have found in OS actually work when I try them in Kitely.
Graham Mills
Posts: 1314
Joined: Sun Dec 23, 2012 2:26 pm
Has thanked: 1134 times
Been thanked: 1141 times

Re: Scripts Library

Post by Graham Mills »

Last time I checked there were some differences between viewers. There's a touch-activated script here
viewtopic.php?f=26&t=759&start=60#p18850
User avatar
Freda Frostbite
Posts: 742
Joined: Sat Mar 29, 2014 2:10 am
Location: Florida, space coast.
Has thanked: 608 times
Been thanked: 769 times

Re: Scripts Library

Post by Freda Frostbite »

Yes, I tried that one. No dice and Bel (my partner in, well, not crime, at The U) can't make it go either. Luckily, I realized we can use the Opensimworld beacon for HG teleports along with the old tried and true map method.
Post Reply