Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Discussion: Communist Tip Ball

Deight Boccara
I AM DEIGHT BOCCARA >:(
Join date: 24 Sep 2005
Posts: 10
11-27-2005 14:49
This tip ball, instead of paying the owner a tip, will split the tip up amongst the people in the room and pay them all equally. Since this is a very silly idea that will never be practially used, I'm making this public domain

CODE

// By Deight Boccara and in the public domain!
// latest version at http://forums.secondlife.com/showthread.php?t=74060
// don't forget to IM Deight any cool improvements!

// these variables are set by the money event so the sensor event can use them
integer m_amount;
key m_giver;

default
{
// when you start this script
state_entry()
{
// make sure you have permissions! please say "yes" to the dialog that pops up!
llRequestPermissions(llGetOwner(),PERMISSION_DEBIT);

// make sure the communist tip ball is communist. feel free to do whatever you want in this bit without fear!
llSetText("Communist Tip Ball!", <1,0,0>, .75); // set the red "Communist Tip Ball" text
llTargetOmega(<0,0,1>,PI/2,1.0); // spin the ball; PI is the speed
llSetPrimitiveParams([PRIM_TEXTURE, 0, "182aed21-dae0-bbf4-d24e-fb342c30adcf", <4,1,0>, <0,0,0>, 3*PI/2]); // Set the texture
}

// when people pay the tip ball...
money(key giver, integer amount)
{
// make sure the sensor event can see these variables, and then...
m_amount = amount;
m_giver = giver;

// start the sensor event. 96 here determines how big--in meters--the influence of communism is
llSensor("", NULL_KEY, AGENT, 96, PI);
}

sensor(integer number)
{
// find out how much everyone gets equally, then count what's left
integer pay = m_amount / number; // (if splitting 52 dollars between 12 people, everyone gets minimum of $4)
integer overflow = m_amount - (pay * number); // (this leaves 4 dollars to give out)

// acknowledge whoever tipped the ball
llShout(0, "Thanks to " + llKey2Name(m_giver) + ", " + (string)(number) +
" people split L$" + (string)(m_amount) + "!");

// if someone paid enough money to split equally among the crowd...
if (pay > 0)
{
// first wave of payment--everyone gets what's determined in "pay" above
integer i;
for (i = 0; i < number; i++)
{
llGiveMoney(llDetectedKey(i), pay);
}

// second wave--randomly choose people to get $1 until we pay the "overflow" amount
for (i = 0; i < overflow; i++)
{
llGiveMoney(llDetectedKey((integer)(llFrand(number))), 1);
}
}

// if someone didn't pay enough to split equally
else
{
// randomly choose people to get $1 until whatever they paid is given out
integer i;
for (i = 0; i < m_amount; i++)
{
llGiveMoney(llDetectedKey((integer)(llFrand(number))), 1);
}
}
}

// if no one is around. I really highly doubt this will ever need to be called.
no_sensor()
{
llGiveMoney(m_giver, m_amount);
llDialog(m_giver, "Man, noone is here!", [], 42);
}
}
Nada Epoch
The Librarian
Join date: 4 Nov 2002
Posts: 1,423
Original Thread
11-27-2005 21:21
/15/33/74060/1.html
_____________________
i've got nothing. ;)
Argent Stonecutter
Emergency Mustelid
Join date: 20 Sep 2005
Posts: 20,263
11-27-2005 21:56
I suggest letting the overflow and small payments accumulate, so that 4 people can each give 13 dollars and the twenty people in the room each get 2 bucks, with enough slack that another 8 will put it over again...
Deight Boccara
I AM DEIGHT BOCCARA >:(
Join date: 24 Sep 2005
Posts: 10
11-28-2005 07:34
From: Argent Stonecutter
I suggest letting the overflow and small payments accumulate, so that 4 people can each give 13 dollars and the twenty people in the room each get 2 bucks, with enough slack that another 8 will put it over again...


Athough I do like the idea of a sub-pay buffer (and the fact that the implementation would be actually quite simple), unless the numbers line up correctly the owner of the ball will get the buffer instead of the people. I could always add in a fancy "force pay" button to press, but that's a button the owner will have to press. This ball is designed primarily so that the owner can set it out and begin not getting any money whatsoever without having to press any buttons.

I do think the ultimate solution to the sub-pay problem is like something what Event Lottery does, which is pay out the overflow dollar by dollar to people who haven't recieved a dollar yet. Then, when everyone got paid a dollar, we start all over again. This ensures fairness without being all button filled.
Argent Stonecutter
Emergency Mustelid
Join date: 20 Sep 2005
Posts: 20,263
11-28-2005 13:03
From: Deight Boccara
Athough I do like the idea of a sub-pay buffer (and the fact that the implementation would be actually quite simple), unless the numbers line up correctly the owner of the ball will get the buffer instead of the people.
House cut?

No, seriously, this shouldn't be a problem. The buffer will never be more than the last number of people in the room, and if there's L$12 there and 20 people, you can have 8 people line up and put L$1 each in and then they'll get them back. Or you can wait until at least 7 people leave and pay another L$1. So even if there's no other allowances made it'll be a minor problem... it's unlikely the owner would ever get more than a few lindens.

But there's all kinds of other options... you could check every minute to see if enough people have left to do a disbursal. Check more often as the number of people drop. Or, if your periodic check fails have it THEN refund the payers starting with the most recent. If a payer has left, pass them over.
Myspoonistoobig Laxness
Registered User
Join date: 3 Nov 2005
Posts: 15
01-05-2006 19:03
Since this is a very silly idea that will never be practially used

I don't know about that. I can see people considering this a small incentive to hang around, so it could be an aid in dwell farming. If you were to change it so that it gave it out at certain intervals, or random ones, people would come and hang around, hoping to get a share without paying :) It goes against the spirit of the thing, but that would be useful
custer Einarmige
oldbie
Join date: 31 Oct 2005
Posts: 17
Mine doesn't work right
03-26-2006 09:32
It just pays the money right back to me. Can't figure out whats wrong.
Yuki Sansome
Trusting Idiot
Join date: 24 Mar 2006
Posts: 12
03-26-2006 17:12
Maybe because you're testing it when you're the only person in the room. Invite a friend over, pay it L$4, and see what happens?