Script LSL de gift giver para freebies e group gifts
Gift giver LSL grátis para lojas de Second Life: toque para receber todos os itens em uma pasta, para todos ou só para membros do grupo com a tag.
Toda loja precisa de um gift giver. Este script entrega tudo que está no Contents de um objeto como uma pasta organizada quando alguém toca nele. Ative GROUP_ONLY e ele vira um quadro de group gifts: só residentes usando a tag do grupo da sua loja recebem o presente.
// 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();
}
}
Livre para usar, alterar e colocar nas suas criações, inclusive nas que você vende.
Como configurar
- Rez uma caixa, placa ou pôster para o seu presente e coloque o script no Contents dele.
- Adicione os itens do presente (roupas, móveis, um landmark, um notecard). Eles precisam ser copiáveis para o próximo dono.
- Para um group gift, defina GROUP_ONLY como TRUE e escolha o grupo do objeto na janela Edit, aba General. Salve o script novamente.
- Toque no giver para testar. O presente chega como uma pasta com o nome do objeto.
Configurações
- GROUP_ONLY: FALSE entrega para todos; TRUE entrega só para residentes usando a tag do grupo do objeto.
- FOLDER_NAME: o nome da pasta onde o presente chega; vazio usa o nome do objeto.
- THANK_YOU e NO_GROUP_TEXT: as mensagens que os residentes veem.
- COOLDOWN_SECONDS: impede que o mesmo avatar pegue o presente várias vezes sem querer.
Dicas
- Troque o presente todo mês trocando os itens no Contents; o script não precisa mudar.
- Coloque um notecard curto no presente com um landmark para sua loja e um agradecimento.
- Cadastre seu presente no WhatSL de graça para mais residentes encontrarem.
Perguntas frequentes
Por que um residente do meu grupo recebe "this gift is for group members"?
Ele está no grupo, mas com outra tag de grupo ativa. Peça para ele deixar o seu grupo como grupo ativo e tocar de novo.
Por que alguns itens não aparecem na pasta?
Itens no-copy para o próximo dono não podem ser entregues em uma pasta. Torne-os copiáveis ou use um giver separado para cada item no-copy.
Posso dar um landmark também?
Sim. Tudo que estiver no Contents, exceto o próprio script, é entregue, incluindo landmarks e notecards.