Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

WANTED: Random notecard giver Script

Vanya Rennahan
Precaching.............
Join date: 29 Dec 2006
Posts: 94
11-16-2007 09:59
Hi,

Looking for someone who can provide me with a random notecard giver script. THe idea of the script is that if someone touches the object, a random notecard out of a possible 20 notecards is given to the individual.

Thanks,

<3

Vanya
Beverly Ultsch
Registered User
Join date: 6 Sep 2007
Posts: 229
11-16-2007 10:49
This should do the job.

integer totalNotecards;

integer randInt(integer n) {
return (integer)llFrand(n + 1);
}

integer randIntBetween(integer min, integer max) {
return min + randInt(max - min);
}

default
{
state_entry() {
totalNotecards = llGetInventoryNumber(INVENTORY_NOTECARD) - 1;
llSetText("Touch me for a notecard", <1.0, 1.0, 1.0>, 0.75);
}
touch_start(integer total_number) {
integer count;
if(totalNotecards > -1) {
for(count = 0; count < total_number; ++count) {
llGiveInventory(llDetectedKey(count), llGetInventoryName(INVENTORY_NOTECARD, randIntBetween(0, totalNotecards)));
}
}
}

changed(integer change) {
if(change & CHANGED_INVENTORY) {
totalNotecards = llGetInventoryNumber(INVENTORY_NOTECARD) -1;
}
}
}

Vanya Rennahan
Precaching.............
Join date: 29 Dec 2006
Posts: 94
11-16-2007 12:23
awesome. Thank you very much. Actually should have searched the forums, there was a similar post a while back. But thanks again :)

Vanya