Difference between revisions of "User:Toady Nakamura/Give Random Object"
Jump to navigation
Jump to search
m (fixed typo, forgot close ">" at end !!) |
m (fix template) |
||
Line 2: | Line 2: | ||
*It will gift a random object to any toucher when touched. | *It will gift a random object to any toucher when touched. | ||
< | <source lang="lsl2"> | ||
default | default | ||
{ | { | ||
Line 17: | Line 17: | ||
} | } | ||
} | } | ||
</ | </source> |
Revision as of 14:26, 11 January 2016
- Put this script and several objects in a prim.
- It will gift a random object to any toucher when touched.
default
{
touch_start(integer total_number)
{
float totalobjects = llGetInventoryNumber(INVENTORY_OBJECT);
// count up how many objects are in inventory
totalobjects = llFrand(totalobjects);
// pick one number from the total number of objects
llGiveInventory(llDetectedKey(0),llGetInventoryName(INVENTORY_OBJECT, (integer)totalobjects));
// give the touching avatar the object which matches that number in inventory
}
}