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.
Toda tienda necesita un gift giver. Este script entrega todo lo que hay en el Contenido de un objeto como una carpeta ordenada cuando alguien lo toca. Activa GROUP_ONLY y se convierte en un tablón de regalos de grupo: solo reciben el regalo los residentes que llevan la etiqueta del grupo de tu tienda.
// Gift Giver (everyone or group only) - free LSL script from WhatSL (https://whatsl.com/scripts/lsl-gift-giver-script)
// Free to use, change and put in your own creations, also ones you sell.
//
// Put this script and your gift items in an object. Touch it to receive everything in its Contents
// (except this script) as one folder. Items must be copyable for the next owner.
// With GROUP_ONLY = TRUE, only residents wearing the same group tag as the object get the gift:
// set the object's group in the Edit window (General tab) first.
integer GROUP_ONLY = FALSE;
string FOLDER_NAME = ""; // "" = use the object's name
string THANK_YOU = "Enjoy your gift! It is in your inventory.";
string NO_GROUP_TEXT = "Sorry, this gift is for group members. Wear the group tag and touch me again.";
integer COOLDOWN_SECONDS = 60; // the same avatar can take the gift again after this time
list gRecent = []; // [avatar key, unix time, ...]
string folderName()
{
if (FOLDER_NAME != "") return FOLDER_NAME;
return llGetObjectName();
}
list giftItems()
{
list out = [];
string me = llGetScriptName();
integer n = llGetInventoryNumber(INVENTORY_ALL);
integer i;
for (i = 0; i < n; ++i)
{
string name = llGetInventoryName(INVENTORY_ALL, i);
if (name != me) out += [name];
}
return out;
}
giveGift(key who, integer sameGroup)
{
if (GROUP_ONLY)
{
// an object without a group would let everyone in, so check that a group is set
key objGroup = llList2Key(llGetObjectDetails(llGetKey(), [OBJECT_GROUP]), 0);
if (objGroup == NULL_KEY)
{
llRegionSayTo(who, 0, "This gift giver is not set up yet.");
return;
}
if (!sameGroup)
{
llRegionSayTo(who, 0, NO_GROUP_TEXT);
return;
}
}
integer now = llGetUnixTime();
integer i = llListFindList(gRecent, [who]);
if (i != -1)
{
if (now - llList2Integer(gRecent, i + 1) < COOLDOWN_SECONDS)
{
llRegionSayTo(who, 0, "You already have this gift. Look for the folder \"" + folderName() + "\" in your inventory.");
return;
}
gRecent = llDeleteSubList(gRecent, i, i + 1);
}
list stuff = giftItems();
if (llGetListLength(stuff) == 0)
{
llRegionSayTo(who, 0, "This gift giver is empty right now.");
return;
}
llGiveInventoryList(who, folderName(), stuff);
llRegionSayTo(who, 0, THANK_YOU);
gRecent += [who, now];
if (llGetListLength(gRecent) > 200) gRecent = llDeleteSubList(gRecent, 0, 1);
}
default
{
state_entry()
{
if (GROUP_ONLY)
{
key objGroup = llList2Key(llGetObjectDetails(llGetKey(), [OBJECT_GROUP]), 0);
if (objGroup == NULL_KEY) llOwnerSay("GROUP_ONLY is on, but this object has no group. Set the group in the Edit window (General tab), then reset the script.");
}
}
touch_start(integer total)
{
integer d;
for (d = 0; d < total; ++d)
{
giveGift(llDetectedKey(d), llDetectedGroup(d));
}
}
changed(integer change)
{
if (change & CHANGED_OWNER) llResetScript();
}
}
Libre para usar, cambiar e incluir en tus creaciones, también en las que vendes.
Cómo configurarlo
- Crea una caja, un cartel o un póster para tu regalo y pon el script en su Contenido.
- Añade los objetos del regalo (ropa, muebles, un landmark, una notecard). Deben ser copiables para el nuevo dueño.
- Para un regalo de grupo, pon GROUP_ONLY en TRUE y asigna el grupo del objeto en la ventana Editar, pestaña General. Guarda el script otra vez.
- Toca el giver para probarlo. El regalo llega como una carpeta con el nombre del objeto.
Ajustes
- GROUP_ONLY: FALSE da a todos; TRUE solo a los residentes que llevan la etiqueta del grupo del objeto.
- FOLDER_NAME: el nombre de la carpeta donde llega el regalo; si está vacío, se usa el nombre del objeto.
- THANK_YOU y NO_GROUP_TEXT: los mensajes que ven los residentes.
- COOLDOWN_SECONDS: evita que el mismo avatar tome el regalo una y otra vez por accidente.
Consejos
- Cambia el regalo cada mes sustituyendo los objetos del Contenido; el script no necesita cambios.
- Incluye una notecard corta en el regalo con un landmark a tu tienda y un agradecimiento.
- Publica tu regalo en WhatSL gratis para que más residentes lo encuentren.
Preguntas frecuentes
¿Por qué un residente de mi grupo recibe "este regalo es para miembros del grupo"?
Está en el grupo, pero tiene activa otra etiqueta de grupo. Pídele que haga activo tu grupo y que vuelva a tocar.
¿Por qué faltan algunos objetos en la carpeta?
Los objetos no copiables para el nuevo dueño no se pueden entregar en una carpeta. Hazlos copiables o usa un giver aparte para cada objeto no copiable.
¿Puedo dar también un landmark?
Sí. Se entrega todo lo que hay en el Contenido excepto el propio script, incluidos landmarks y notecards.