Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Help with adding a floating text to a script

Dick Spad
Life is a Pose Ball ....
Join date: 29 Oct 2007
Posts: 205
09-29-2009 11:01
I’m using the following tipjar script, and it works like a charm. Problem is when the jar is not active (no one signed in to it) there is no floating text to let people that’s it a tipjar or they need to click on it to sign in. How can I add that floating text to this while the jar is inactive, letting them know to login? Any help is much appreciated.

CODE

// global constants

string CUSTOM_TEXT = "TIP THE SEXY DANCER!!";
string DEFAULT_TEXT = "";

list DEFAULT_QUICK_PAY_AMOUNTS = [5, 10, 20, 50];

integer DEFAULT_PRICE = PAY_DEFAULT;

// This value is the percentage of tip commissions that go to the tip jar owner.
// For example,
// 90% of the tip to the registered user, 10% of the tip to the owner:
// float OWNER_COMMISSION = 10.0;
// or
// 95% of the tip to the registered user, 5% of the tip to the owner:
// float OWNER_COMMISSION = 5.0;
//
float OWNER_COMMISSION = 0.0;

string DEFAULT_DONOR = "nobody";

float PARTICLE_EFFECT_TIMER = 4.0;

vector PARTICLE_EFFECT_COLOUR = <1.0, 0.0, 1.0>;

vector FLOATING_TEXT_COLOUR = <1.0, 0.0, 0.0>;

// If you have more than one tip jar, they should each use a different DIALOG_CHANNEL!
//
integer DIALOG_CHANNEL = -25879;

string DIALOG_REGISTER_TEXT = "Would you like to register with this tip jar?";
string DIALOG_UNREGISTER_TEXT = "Would you like to unregister the user of this tip jar?";
string DIALOG_ACK = "OK";
string DIALOG_NACK = "No Thanks";

string WRONG_GROUP_TEXT = "Sorry, you need to change your active group to be able to register with this tip jar.";

// global variables

integer last_donation = 0;
integer total_donations = 0;

integer dialog_channel_handle = -1;

key last_donor = NULL_KEY;

key owner_id = NULL_KEY;
key registered_id = NULL_KEY;

write_floating_text()
{
string donor = DEFAULT_DONOR;

if (last_donor != NULL_KEY)
{
donor = llKey2Name(last_donor);
}
llSetText(CUSTOM_TEXT +
"\n" +
"Last donation: L$" +
(string)last_donation +
" by " + donor + ".\n" +
"Total donations: L$" +
(string)total_donations + ".\n",
FLOATING_TEXT_COLOUR,
1.0);
}

default_floating_text()
{
llSetText(DEFAULT_TEXT, FLOATING_TEXT_COLOUR, 1.0);
}

enable_particle_effect()
{
llParticleSystem(
[PSYS_PART_FLAGS, PSYS_PART_EMISSIVE_MASK,
PSYS_SRC_PATTERN, PSYS_SRC_PATTERN_ANGLE,
PSYS_PART_START_COLOR, PARTICLE_EFFECT_COLOUR,
PSYS_SRC_ANGLE_BEGIN, (DEG_TO_RAD * -90),
PSYS_SRC_ANGLE_END, (DEG_TO_RAD * 90),
PSYS_SRC_BURST_RATE, 0.0,
PSYS_SRC_BURST_PART_COUNT, 1,
PSYS_PART_MAX_AGE, 0.5
] );
}

disable_particle_effect()
{
llParticleSystem([]);
}

default
{
on_rez(integer start_param)
{
llResetScript();
}

state_entry()
{
// Request Owners permission to debit money (to pay the registered tip jar user).
llRequestPermissions(llGetOwner(),
PERMISSION_DEBIT);
state unregistered;
}
}

state unregistered
{
on_rez(integer start_param)
{
llResetScript();
}

state_entry()
{
owner_id = llGetOwner();
registered_id = NULL_KEY;
last_donor = NULL_KEY;
last_donation = 0;
total_donations = 0;
dialog_channel_handle = llListen(DIALOG_CHANNEL, "", "", DIALOG_ACK);
llSetPayPrice(DEFAULT_PRICE, DEFAULT_QUICK_PAY_AMOUNTS);
default_floating_text();
llOwnerSay("Tip Jar at " + (string)llGetPos() + " is initialized.");
}

touch(integer detected)
{
key id = llDetectedKey(0);
if (llSameGroup(id) == TRUE)
{
// send dialog asking if they want to register
llDialog(id, DIALOG_REGISTER_TEXT, [DIALOG_ACK, DIALOG_NACK], DIALOG_CHANNEL);
}
else
{
llInstantMessage(id, WRONG_GROUP_TEXT);
}
}

listen(integer channel, string name, key id, string message)
{
if (llSameGroup(id) == TRUE)
{
registered_id = id;
state registered;
}
else
{
llInstantMessage(id, WRONG_GROUP_TEXT);
}
}

state_exit()
{
llListenRemove(dialog_channel_handle);
}
}

state registered
{
on_rez(integer start_param)
{
llResetScript();
}

state_entry()
{
dialog_channel_handle = llListen(DIALOG_CHANNEL, "", "", DIALOG_ACK);
llSetPayPrice(DEFAULT_PRICE, DEFAULT_QUICK_PAY_AMOUNTS);
default_floating_text();
write_floating_text();
llOwnerSay("Tip Jar at " + (string)llGetPos() + " is initialized.");

}

money(key id, integer amount)
{
last_donor = id;
last_donation = amount;
total_donations += amount;
llSay(PUBLIC_CHANNEL, "Thank you for the donation, " + llKey2Name(last_donor) + "!");
llOwnerSay("Tip Jar at " +
(string)llGetPos() +
" was paid " +
(string)last_donation +
" by " +
llKey2Name(last_donor) + ".");
llInstantMessage(registered_id, "Tip Jar at " +
(string)llGetPos() +
" was paid " +
(string)last_donation +
" by " +
llKey2Name(last_donor) + ".");
write_floating_text();

// keep commission percentage for owner and pay the rest to the registered user.
float commission_percentage = OWNER_COMMISSION / 100;
integer owner_commission = llRound((float)last_donation * commission_percentage);

integer user_tip = last_donation - owner_commission;
llGiveMoney(registered_id, user_tip);

enable_particle_effect();
llSetTimerEvent(PARTICLE_EFFECT_TIMER);
}

timer()
{
disable_particle_effect();
llSetTimerEvent(0.0);
}

touch(integer detected)
{
key id = llDetectedKey(0);
if ((id == registered_id) || (id == owner_id))
{
// ask the registered user if they want to unreg.
llDialog(id, DIALOG_UNREGISTER_TEXT, [DIALOG_ACK, DIALOG_NACK], DIALOG_CHANNEL);
}
}

listen(integer channel, string name, key id, string message)
{
if ((id == registered_id) || (id == owner_id))
{
// unregister the tip jar user.
llInstantMessage(registered_id,
"You have been unregistered from this tip jar by " +
llKey2Name(id) +
".");
state unregistered;
}
}

state_exit()
{
llListenRemove(dialog_channel_handle);
}
}

_____________________
Come visit SL Habitat



----------------------------------------------------------------------

Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
09-29-2009 11:07
Um..... Just at a very quick glance, it looks as if you already scripted that option into it. Right at the top of the script, you have a variable named DEFAULT_TEXT. It's currently set to an empty value, so type whatever you want between the quotes and it ought to show up the way you want. If not, come back and someone will look more carefully than I just did. ;)
_____________________
It's hard to tell gender from names around here but if you care, Rolig = she. And I exist only in SL, so don't ask.... ;)

Look for my work in XStreetSL at
Dick Spad
Life is a Pose Ball ....
Join date: 29 Oct 2007
Posts: 205
09-29-2009 13:53
From: Rolig Loon
Um..... Just at a very quick glance, it looks as if you already scripted that option into it. Right at the top of the script, you have a variable named DEFAULT_TEXT. It's currently set to an empty value, so type whatever you want between the quotes and it ought to show up the way you want. If not, come back and someone will look more carefully than I just did. ;)


Thanks Rolig .. I'll give that a look over!!!
_____________________
Come visit SL Habitat



----------------------------------------------------------------------