Difference between revisions of "User:Toady Nakamura/Give Anything"
m (→More than one type of thing?: fix error) |
m (</source>) |
||
Line 8: | Line 8: | ||
== Give Landmark == | == Give Landmark == | ||
< | <source lang="lsl2"> | ||
default | default | ||
Line 17: | Line 17: | ||
} | } | ||
} | } | ||
</ | </source> | ||
== Give Object == | == Give Object == | ||
< | <source lang="lsl2"> | ||
default | default | ||
Line 29: | Line 29: | ||
} | } | ||
} | } | ||
</ | </source> | ||
== Give Notecard == | == Give Notecard == | ||
< | <source lang="lsl2"> | ||
default | default | ||
Line 41: | Line 41: | ||
} | } | ||
} | } | ||
</ | </source> | ||
== More than one type of thing? == | == More than one type of thing? == | ||
This script hands all notecards and textures in a prim to anyone touching it - neatly packed in one folder, but it won't give away the script itself! Thanks to Foolish Frost for the initial version of this script! | This script hands all notecards and textures in a prim to anyone touching it - neatly packed in one folder, but it won't give away the script itself! Thanks to Foolish Frost for the initial version of this script! | ||
<source lang="lsl2"> | |||
vector fcolor = < 1.0,1.0,1.0 >; // color for floating text | vector fcolor = < 1.0,1.0,1.0 >; // color for floating text | ||
string ftext = "Put your Floating Message Here"; | string ftext = "Put your Floating Message Here"; | ||
Line 93: | Line 93: | ||
} | } | ||
} | } | ||
</ | </source> | ||
== Another No-script Giver == | == Another No-script Giver == | ||
This is a slightly "fancier" scripting way to give all but not the script. It also checks that the giver has permissions to give away the object. | This is a slightly "fancier" scripting way to give all but not the script. It also checks that the giver has permissions to give away the object. From a gift box from Yadni Monde that I got in 2009. | ||
< | <source lang="lsl2"> | ||
list inventory = []; | list inventory = []; | ||
default | default | ||
Line 122: | Line 122: | ||
} | } | ||
} | } | ||
</ | </source> | ||
Visit my LSL wiki page for my library of simple scripts ! [[User:Toady Nakamura|Toady Nakamura]] |
Latest revision as of 13:35, 11 January 2016
There's five scripts on this page; three simple and one more complicated.
The top scripts are to be used if you only have *one* thing to give away. Use the bottom script if you have more than one thing to give away, even if they are of different types!
Place what you wish to give in the prim, and then select the appropriate script to give it!
Note: All givers will fail if you do not have permissions to give away the items.
Give Landmark
default
{
touch_start(integer total_number)
{
llGiveInventory(llDetectedKey(0), llGetInventoryName(INVENTORY_LANDMARK, 0));
}
}
Give Object
default
{
touch_start(integer total_number)
{
llGiveInventory(llDetectedKey(0), llGetInventoryName(INVENTORY_OBJECT, 0));
}
}
Give Notecard
default
{
touch_start(integer total_number)
{
llGiveInventory(llDetectedKey(0), llGetInventoryName(INVENTORY_NOTECARD, 0));
}
}
More than one type of thing?
This script hands all notecards and textures in a prim to anyone touching it - neatly packed in one folder, but it won't give away the script itself! Thanks to Foolish Frost for the initial version of this script!
vector fcolor = < 1.0,1.0,1.0 >; // color for floating text
string ftext = "Put your Floating Message Here";
string foldername = "Put the name of the Folder they will get Here.";
list content= []; // make empty list to hold data
default
{
state_entry()
{
llSetText(ftext, fcolor, 1.0);
// counts up and adds to content every landmark found
integer c = llGetInventoryNumber(INVENTORY_LANDMARK);
integer i = 0;
for (i = 0; i < c; i = i + 1) // can also be written ... for (; i < c; ++i)
{
content += llGetInventoryName(INVENTORY_LANDMARK, i);
}
// counts up and adds to content every notecard found
integer d = llGetInventoryNumber(INVENTORY_NOTECARD);
integer n = 0;
for (n = 0; n < d; n = n + 1) // can also be written ... for (; n < d; ++n)
{
content += llGetInventoryName(INVENTORY_NOTECARD, n);
}
// counts up and adds to content every object found
integer bob = llGetInventoryNumber(INVENTORY_OBJECT);
integer numma = 0;
for (numma = 0; numma < bob; numma = numma + 1)// can also be written ...for (; numma < bob; ++numma)
{
content += llGetInventoryName(INVENTORY_OBJECT, numma);
}
}
touch_start(integer total_number)
{
llGiveInventoryList(llDetectedKey(0), foldername, content); // gives the contents to toucher
llOwnerSay(llDetectedName(0) + " got supplies."); // tells Owner toucher got stuff
}
}
Another No-script Giver
This is a slightly "fancier" scripting way to give all but not the script. It also checks that the giver has permissions to give away the object. From a gift box from Yadni Monde that I got in 2009.
list inventory = [];
default
{
state_entry()
{
integer i;
for ( i = 0; i < llGetInventoryNumber(INVENTORY_ALL); i++)
{
string item = llGetInventoryName(INVENTORY_ALL, i);
if (llGetInventoryPermMask(item, MASK_OWNER) & PERM_COPY)
{
inventory += [item]; // this adds all the giveable objects
}
}
integer index = llListFindList(inventory, [llGetScriptName()]);
inventory = llDeleteSubList(inventory, index, index); // this removes the script !!
}
touch_start(integer total_number)
{
llGiveInventoryList(llDetectedKey(0), llGetObjectName(), inventory);
}
}
Visit my LSL wiki page for my library of simple scripts ! Toady Nakamura