Themabewertung:
  • 0 Bewertung(en) - 0 im Durchschnitt
  • 1
  • 2
  • 3
  • 4
  • 5
Suche Garagentor script
#2
Ich hab da was aus unserer Feuerwache in Westend:

Code:
/*
* Smooth Rotating Linked Door With Hinge
*
* By: Lyn Mimistrobell
* Version: 1.1
* License: Do whatever you like with it, just don't blame me if you break it :)
*/

/*
* 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      = <2.75, 1.9, 0.0>;

/*
* Define how fast the door opens, in seconds
*/
float       SECONDS_TO_ROTATE   = 1.0;

/*
* Define after how much time the door should close automatically, in seconds;
* set to 0.0 to disable automatic closing
*/
float       AUTO_CLOSE_TIME     = 10.0;

/*
* Define a sound that plays when the door starts to open; set to NULL_KEY
* for no sound.
*/
key         SOUND_ON_OPEN       = "e5e01091-9c1f-4f8c-8486-46d560ff664f";

/*
* Define a sound that plays when the door has closed; set to NULL_KEY
* for no sound.
*/
key         SOUND_ON_CLOSE      = "88d13f1f-85a8-49da-99f7-6fa2781b2229";

/*
* Define the volume of the opening and closing sounds
*/
float       SOUND_VOLUME        = 1.0;

/*
* 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();
    }
    collision_start(integer Dummy)
    {
        if (gClosed)
        {
            doOpenOrClose();
        }
    }
    timer() {
        llSetTimerEvent(0.0);

        /*
         * Close the door if it isn't already closed
         */
        if (! gClosed)
            doOpenOrClose();
    }
}

Musst du die Parameter ein bischen anpassen - evtl. nach dem Motto "Probieren geht über studieren." Wink )
Ich fürchte die Sounds werden so wie sie hier drinstehen erstmal nicht funzen - einfach entsprechend eigene Sounds einsetzen.
Wer nicht weiss wohin er will, der kommt leicht woanders hin.
[-] The following 2 users say Thank You to Anachron for this post:
  • Dorena Verne, Kalkofe
Zitieren


Nachrichten in diesem Thema
Suche Garagentor script - von Kalkofe - 19.07.2024, 17:01
RE: Suche Garagentor script - von Anachron - 19.07.2024, 18:21
RE: Suche Garagentor script - von Kalkofe - 20.07.2024, 10:19
RE: Suche Garagentor script - von Anachron - 20.07.2024, 11:41
RE: Suche Garagentor script - von Manfred Aabye - 20.07.2024, 12:06

Möglicherweise verwandte Themen…
Thema Verfasser Antworten Ansichten Letzter Beitrag
  Suche Lichtscript LadyContessa Barbosa 8 10.070 21.03.2024, 16:22
Letzter Beitrag: Manfred Aabye
Question Tür script gesucht, Tür soll bei Eintritt ein paar meter vorher öffnen Kalkofe 9 2.381 11.10.2023, 05:37
Letzter Beitrag: Christoph Balhaus
  Rufknopf Script für Aufzug gesucht Xenos Yifu 4 2.857 03.04.2022, 19:09
Letzter Beitrag: Mareta Dagostino
  Geber/ Rezz Script Xenos Yifu 10 6.510 28.11.2020, 14:28
Letzter Beitrag: Kubwa
  Suche Script Gruppe Titoss 4 7.525 27.11.2020, 14:52
Letzter Beitrag: Dorena Verne

Gehe zu:


Benutzer, die gerade dieses Thema anschauen: 1 Gast/Gäste