Simple Disappearing HoverText
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.
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();
}
}
}
Script Library |
Examples