Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Help splitting up a list into multiples (out of memory)

Irish Mills
Registered User
Join date: 19 Mar 2007
Posts: 56
03-25-2008 19:04
Hi =)

I run a private park on one of my islands with a theatre, games and the works. There is a tip jar out that collects 10L donations from group members that choose to leave one and records a list of the donators , and every few weeks is use the following script to draw the name of one of the donators out of the hat and that person gets to pick the next game/item/etc that we add to the island from a list. If there is enough money left we click and pick again and so on.

My problem is the tenants are very good people and have started making a game of donating and I am afraid after one of thier parties the list im using may run out of script memory and some of the data could get lost. I know you can split up this sort of thing into multiple lists but i cant figure out how to do it and still have it pick at random from the whole list when it comes time to get the name.

any help on this would be greatly appreciated
THanks!

this is the list portion of my script theres a bunch of other junk like email notifications when people tip and stuff i didn't paiste in here for the sake of anti clutter

CODE


integer price = 10;

list contributors = [];
integer CL;
integer count;
key winner;

default
{
state_entry()
{
//Request permissions to debit owner's account.
llSetPayPrice(PAY_HIDE, [price, PAY_HIDE, PAY_HIDE, PAY_HIDE]);
llRequestPermissions(llGetOwner(), PERMISSION_DEBIT);
}
run_time_permissions(integer perms)
{
if(perms & PERMISSION_DEBIT)
}
else
{//Permissions was denied.
state idol;
}
}

touch_start(integer num_detected)
{
CL = llGetListLength(contributors);
count = llRound(llFrand(CL));
winner = (key)llList2String(contributors,count);
llSay(0,"The winner is" + (string)winner + ".");
contributors = llDeleteSubList(contributors,count,count);
}
money(key tipper, integer amount)
{
if(amount == price)
{ //if amount is paid thank the person and add to list
llInstantMessage(tipper, "Thank you for your Donation!");
contributors = contributors + [llKey2Name(tipper)];
}
}
Xhawkx Holden
Registered User
Join date: 1 Nov 2006
Posts: 86
03-26-2008 13:11
Lets see if I can explain my ideas clearly...
Here is what I would do..
I would have multiple "memory" scripts...
called 1-20 lets say
each one of these scripts would maintain a list of say 30 names...
thats 600 names!!..
you would have a primary script that accepts the payments and keeps a running total of how many have donated so far.....

for the 1st 30 names that donate... pass the donators name and amount (if so desired) to script number 1.

script 1 hears the message targeted to it, and adds the name to it's list..

When you reach donator 31 up to 60.. these donators and amounts get sent to script 2... and so on...

When time to pick a random winner... just generate a random number between 1 and the total donators. You can now fetch the name from the appropriate script/list.