Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Simple object giver - by Bugs Larnia
- // Created 2009-12-19
- // 2019-12-6 - BL: Replaced llInstantMessage by llRegionSayTo and updated variable names
- // This script will give all inventory, except this script to anyone who touches the container
- // This script is freeware and may be distributed and used freely
- // Please keep annotations
- list glInventory;
- // This user defined function (UDF) puts the inventory in a list
- GetInventoryList()
- {
- integer i;
- glInventory = [];
- // Build the list of things to give
- for (i = 0; i < llGetInventoryNumber(INVENTORY_ALL); ++i)
- {
- glInventory += llGetInventoryName(INVENTORY_ALL, i);
- }
- // Delete this giver script from the list
- i = llListFindList(glInventory, [llGetScriptName()]);
- if (~i)
- {
- glInventory = llDeleteSubList(glInventory, i, i);
- }
- }
- SayTo(key pkId, string psMsg)
- {
- if (pkId == NULL_KEY)
- {
- return;
- }
- llRegionSayTo(pkId, 0, psMsg);
- }
- default
- {
- state_entry()
- {
- GetInventoryList(); // Build the inventory list
- }
- changed(integer piChange)
- {
- // Make sure the list is rebuilt when a new object is dropped in or removed
- if (piChange & CHANGED_INVENTORY)
- {
- GetInventoryList();
- }
- // Reset script on owner change
- if (piChange & CHANGED_OWNER)
- {
- llResetScript();
- }
- }
- touch_start(integer piNum)
- {
- integer iLength = llGetListLength(glInventory); // Get the list length
- string sFolder = llGetObjectName(); // Folder name
- key kId = llDetectedKey(0); // Get toucher's key
- // If more items, then give a folder
- if (iLength > 1)
- {
- llGiveInventoryList(kId, sFolder, glInventory);
- SayTo(kId, "Please look in your inventory for a folder called: " + sFolder);
- }
- // If only one item, just give the item
- else if (iLength == 1)
- {
- string sName = llList2String(glInventory, 0);
- llGiveInventory(kId, sName);
- SayTo(kId, "Please look in your inventory for an item called: " + sName);
- }
- // No items present; inform the toucher
- else
- {
- SayTo(kId, "Sorry, there seems to be no inventory present.");
- }
- }
- on_rez(integer piParam)
- {
- llResetScript();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement