Second Life hoy en un solo lugar Regalos y freebies actualizados cada hora 7 idiomas Gratis publicar tu tienda
12:49 SLT Publica tu evento+ Publicar
Problema en el grid
  • Programado: Scheduled Billing Maintenance, lun, 16 nov 09:30–10:30 SLT
  • Estado del grid: Unscheduled Group Chat Maintenance (investigating)
  • Ahora: Servicio sabático Unitarian Universalist en UUtopia
  • Ahora: The Dharma of Community: Sociedad budista y el householder
  • Ahora: Harvest Fest de SLCS: juegos, música y diversión
  • 14:00 SLT: NAD GOUGH en vivo en Moondance en Cascadia, 14:00 SLT
  • Noticias: REZZ MALL: marcas de Second Life en un centro comercial web
  • Viewer: Second Life Viewer 26.5 moderniza el chat
  • Programado: Scheduled Billing Maintenance, lun, 16 nov 09:30–10:30 SLT
  • Estado del grid: Unscheduled Group Chat Maintenance (investigating)
  • Ahora: Servicio sabático Unitarian Universalist en UUtopia
  • Ahora: The Dharma of Community: Sociedad budista y el householder
  • Ahora: Harvest Fest de SLCS: juegos, música y diversión
  • 14:00 SLT: NAD GOUGH en vivo en Moondance en Cascadia, 14:00 SLT
  • Noticias: REZZ MALL: marcas de Second Life en un centro comercial web
  • Viewer: Second Life Viewer 26.5 moderniza el chat
Script LSL

Script de puerta en LSL: se abre al tocar y se cierra sola

Script de puerta gratuito en LSL para Second Life. Tócala para abrirla y cerrarla; la puerta gira sobre sus bisagras y se cierra sola tras unos segundos. Sonidos opcionales.

55 líneas ·

Un script de puerta sencillo y fiable para Second Life. Toca la puerta y se abrirá girando sobre sus bisagras; tócala de nuevo para cerrarla, o deja que se cierre sola tras unos segundos. Recuerda dónde está la puerta cerrada cada vez que se abre, así que puedes moverla más adelante y seguirá funcionando.

lsl-door-script.lsl · 55 líneas Comprobar este script
// Touch Door with auto-close - free LSL script from WhatSL (https://whatsl.com/scripts/lsl-door-script)
// Free to use, change and put in your own creations, also ones you sell.
//
// Put this script in an upright door that is its own object (not linked to the house).
// The door's width must run along its X axis (the red arrow in the Edit window).
// Touch to open, touch again to close. It also closes by itself after AUTO_CLOSE seconds.

float   OPEN_ANGLE  = 90.0;  // degrees to swing; use -90.0 to open the other way
float   AUTO_CLOSE  = 10.0;  // seconds before it closes by itself; 0.0 = stay open
integer HINGE_SIDE  = 1;     // 1 = hinge on the +X edge, -1 = hinge on the -X edge
string  OPEN_SOUND  = "";    // optional: a sound name in the door's Contents, or a sound UUID
string  CLOSE_SOUND = "";

integer  gOpen = FALSE;
vector   gClosedPos;
rotation gClosedRot;

openDoor()
{
    // remember where the closed door is, so the door can be moved and still work
    gClosedPos = llGetPos();
    gClosedRot = llGetRot();
    vector size = llGetScale();
    vector hinge = gClosedPos + <HINGE_SIDE * size.x * 0.5, 0.0, 0.0> * gClosedRot;
    rotation turn = llEuler2Rot(<0.0, 0.0, OPEN_ANGLE * DEG_TO_RAD>);
    llSetLinkPrimitiveParamsFast(LINK_THIS, [
        PRIM_POSITION, hinge + (gClosedPos - hinge) * turn,
        PRIM_ROTATION, gClosedRot * turn
    ]);
    if (OPEN_SOUND != "") llPlaySound(OPEN_SOUND, 1.0);
    gOpen = TRUE;
    if (AUTO_CLOSE > 0.0) llSetTimerEvent(AUTO_CLOSE);
}

closeDoor()
{
    llSetTimerEvent(0.0);
    llSetLinkPrimitiveParamsFast(LINK_THIS, [PRIM_POSITION, gClosedPos, PRIM_ROTATION, gClosedRot]);
    if (CLOSE_SOUND != "") llPlaySound(CLOSE_SOUND, 1.0);
    gOpen = FALSE;
}

default
{
    touch_start(integer total)
    {
        if (gOpen) closeDoor();
        else openDoor();
    }

    timer()
    {
        closeDoor();
    }
}

Libre para usar, cambiar e incluir en tus creaciones, también en las que vendes.

Cómo configurarla

  1. Crea o rezea tu puerta. Debe estar de pie y ser un objeto independiente, no enlazado a la casa.
  2. Comprueba que el ancho de la puerta vaya a lo largo de su eje X (la flecha roja de la ventana Editar). Si no es así, rota la puerta con las herramientas de construcción o intercambia los valores de tamaño.
  3. Abre la pestaña Contenido, haz clic en Nuevo script, pega el script y guarda.
  4. Toca la puerta. Si se abre en la dirección equivocada, pon OPEN_ANGLE en -90.0. Si gira por el borde equivocado, pon HINGE_SIDE en -1.

Ajustes

  • OPEN_ANGLE: cuánto gira la puerta, en grados.
  • AUTO_CLOSE: segundos antes de que la puerta se cierre sola; 0.0 la mantiene abierta hasta que alguien la toque.
  • HINGE_SIDE: qué borde vertical es la bisagra.
  • OPEN_SOUND / CLOSE_SOUND: el nombre de un sonido del Contenido de la puerta, o el UUID de un sonido. Déjalo vacío para que no suene nada.

Consejos

  • Para puertas dobles, pon el script en ambas puertas y configura una con OPEN_ANGLE 90.0 y la otra con -90.0.
  • Las puertas que forman parte de una casa enlazada necesitan otro método. La solución más sencilla es desenlazar la puerta y dejarla como objeto independiente.

Preguntas frecuentes

¿Por qué mi puerta gira alrededor de su centro?

El script rota alrededor de un borde que calcula a partir del tamaño X de la puerta. Si la puerta gira por el centro, su ancho no va a lo largo del eje X. Rota la puerta para que la flecha roja recorra su ancho.

¿Puedo bloquear la puerta?

Esta versión se abre para todo el mundo. Para una puerta bloqueada, añade una comprobación al inicio de touch_start, por ejemplo: if (llDetectedKey(0) != llGetOwner()) return;

¿El script causa lag?

No. Solo se ejecuta cuando alguien toca la puerta y cuando el temporizador la cierra.

Comprueba tu propio script: Comprobador de sintaxis LSL →

Más scriptsTodos los scripts
Script LSL · 69 líneas

LSL sit and pose script for chairs and pose balls

Free LSL sit script for Second Life chairs, benches and pose balls: sit and play your own animation, set the sit position, hide the ball while in use.

Script LSL · 96 líneas

LSL tip jar script with thank-you message and total

Free LSL tip jar script for Second Life clubs, DJs, hosts and stores: quick pay buttons, a thank-you message, the total and last tipper in floating text.

Script LSL · 101 líneas

Script LSL para regalos gratis y regalos de grupo en Second Life

Script LSL gratis para dar regalos en tiendas de Second Life: toca y recibe todos los objetos en una carpeta, para todos o solo para miembros del grupo con la etiqueta.