Simple Disappearing HoverText
De DigiWiki.
This is a simple script that adds hovertext to the prim that it is in.
When an Avatar sits on the prim, it removes the hovertext.
Note, the prim MUST have a llSitTarget defined for this to work.
string Text = "Sit here\n \n \n \n"; vector TextColor = <1.0,1.0,1.0>; vector TextAlpha = 1.0; integer hidden; default { state_entry() { llSetText( Text, TextColor, TextAlpha ); hidden = FALSE; } changed( integer change ) { if( change & CHANGED_LINK ) { integer temp = llAvatarOnSitTarget() != NULL_KEY; if( temp != hidden ) { if(temp) { llSetText( "", ZERO_VECTOR, 0 ); } else { llSetText( Text, TextColor, TextAlpha ); } hidden = temp; } llSleep(0.5); } } }
You might ask, "why keeping track of if the text is hidden?" When you link multiple prims with sit targets together any time someone stands up every script in the linked object has a changed event triggered (where applicable). If each script did not keep track of this data, ever script in the object would cause a full update for prim they are in. Full updates contribute to lag.
Here is a different way of doing it.
string sHoverText = "Sit here\n \n \n \n"; ShowHover() { //llOwnerSay( "Showing" ); llSetText( sHoverText, <1.0,1.0,1.0>, 1.0 ); //add a slight delay to avoid sending too many messages to the prim llSleep( 0.5 ); } HideHover() { //llOwnerSay( "Hiding" ); llSetText( "", <1.0,1.0,1.0>, 0.0 ); //add a slight delay to avoid sending too many messages to the prim llSleep( 0.5 ); } default { state_entry() { ShowHover(); } changed( integer iChange ) { key kAgent = NULL_KEY; if( iChange & CHANGED_LINK ) { kAgent = llAvatarOnSitTarget(); //llOwnerSay( "kAgent=" + (string)kAgent ); if( kAgent == NULL_KEY ) ShowHover(); else HideHover(); } } }


