Difference between revisions of "Give random object"
Jump to navigation
Jump to search
Emmas Seetan (talk | contribs) |
Kireji Haiku (talk | contribs) m (improved readability) |
||
Line 1: | Line 1: | ||
== Yes, the random object giver == | == Yes, the random object giver == | ||
Place this in an object with a big inventory (well, doesn't have to have LOTS in it) and touch to | Place this in an object with a big inventory (well, doesn't have to have LOTS in it) and touch to receive a random object. | ||
<lsl> | |||
//Emmas Seetan | |||
default | |||
{ | |||
touch_start(integer num_detected) | |||
{ | |||
// the key of the avatar touching | |||
key id = llDetectedKey(0); | |||
integer randomIndex = llGetInventoryNumber(INVENTORY_OBJECT); | |||
// random >> [0.0, max) | |||
randomIndex = (integer)llFrand(randomIndex); | |||
string itemName = llGetInventoryName(INVENTORY_OBJECT, randomIndex); | |||
llGiveInventory(id, itemName); | |||
} | |||
} | |||
</lsl> |
Revision as of 11:25, 18 October 2012
Yes, the random object giver
Place this in an object with a big inventory (well, doesn't have to have LOTS in it) and touch to receive a random object.
<lsl> //Emmas Seetan
default {
touch_start(integer num_detected) { // the key of the avatar touching key id = llDetectedKey(0);
integer randomIndex = llGetInventoryNumber(INVENTORY_OBJECT); // random >> [0.0, max) randomIndex = (integer)llFrand(randomIndex);
string itemName = llGetInventoryName(INVENTORY_OBJECT, randomIndex);
llGiveInventory(id, itemName); }
} </lsl>