Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Donation Pot for beginners

Lazerus Glitterbuck
Wascally Wabbit
Join date: 6 Jan 2005
Posts: 14
04-28-2005 18:29
OK ive managed to make a basic donation pot from the example kindly given in the scripting library forum...
But many ive seen keep a running tally of the amount donated. Anyone able to help me with this or tell me where I can buy one in game?
Jillian Callahan
Rotary-winged Neko Girl
Join date: 24 Jun 2004
Posts: 3,766
04-28-2005 18:40
CODE
integer total;

default
{
state_entry()
{
total = 0;
}

money(key id, integer amt)
{
total += amt;
llWhisper(0, "Thanks for the " + (string)amt + " donation, " + llKey2Name(id) + "!");
llWhisper(0, "That makes " + (string)total + " so far!");
}
}
_____________________
Lazerus Glitterbuck
Wascally Wabbit
Join date: 6 Jan 2005
Posts: 14
04-28-2005 18:44
Thanks for the help but it throws me a syntax error... >.<

Addendum I fixed the syntax error by simply removing "state"
But this isnt QUITE what im after. I want one that displays the total in floating text above the donation box so others can see it.
Jillian Callahan
Rotary-winged Neko Girl
Join date: 24 Jun 2004
Posts: 3,766
04-28-2005 19:12
It's an example, is all.

Just add llSetText((string)total + " donated so far.", <1,1,1>, 1.0); after the last llWhisper().

integer total;

CODE
default
{
state_entry()
{
total = 0;
llSetText("L$" + (string)total + " donated so far.", <1,1,1>, 1.0);
}

money(key id, integer amt)
{
total += amt;
llWhisper(0, "Thanks for the L$" + (string)amt + " donation, " + llKey2Name(id) + "!");
llWhisper(0, "That makes L$" + (string)total + " so far!");
llSetText("L$" + (string)total + " donated so far.", <1,1,1>, 1.0);
}
}
_____________________