Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Dynamic Unicode Hovertext

Eadoin Welles
Registered User
Join date: 5 Jan 2007
Posts: 149
11-07-2007 03:16
This script allows you to dinamically change the hovertext of any object from chat or notecard. It also support most l2r unicode scripts. So now you can set hovertext in Italian, French, German, Russian, Greek, Chinese, Japanese, Korean or other languages. Hebrew and Arabic are not supported yet, but they could in future.


Just copy and paste to an editor, and change all occurrences of "·" to " ":

//·
//·Script:··Repeater
//·Author:··Eadoin·Welles·(Dario·de·Judicibus·<ddj@mclink.it>;)
//·Created:·7·November·2007
//·Purpose:·Receive·text·to·be·shown·in·over·text·or·to·be·read·from·notecard
//·License:·Commons·Creative·3.0
//

//·Constants
integer·CHANNEL_NUM·=·101·;
list····VALID_COMMANDS =·["say","show","reset"]·;

//·Variables
string··gsNotecardName·;
integer·giNotecardLine·;
integer·giNumNotecardLines·;
key·····gkNotecardRequest·;
list····glCardData·;

//·Functions
init()
{
····llSetText("",<0.0,0.0,0.0>,0.0)·;
}

reset()
{
····llResetScript()·;
····init()·;
}

resetCardData()
{
····gsNotecardName·=·""·;
····giNotecardLine·=·0·;
····giNumNotecardLines·=·0·;
····gkNotecardRequest·=·NULL_KEY·;
····glCardData·=·[]·;
}

showCard()
{
····if·(giNumNotecardLines·>·0)
····{
········string·sText·=·llDumpList2String(glCardData,"\n";)·;
········llSetText(sText,<1.0,1.0,1.0>,1.0)·;
····}
}

integer·checkCard(string·asCardName)
{
····integer·iType·=·llGetInventoryType(asCardName)·;
····return·(iType·==·INVENTORY_NOTECARD)·;
}

doIt(string·asCommand,·list·alParameters)
{
····(asCommand·==·"reset";)
····{
········reset()·;
····}
····else·if·(asCommand·==·"say";)
····{
········string·sText·=·llDumpList2String(alParameters,"·";)·;
········llSetText(sText,<1.0,1.0,1.0>,1.0)·;
····}
····else·if·(asCommand·==·"show";)
····{
········resetCardData()·;
········gsNotecardName·=·(string)llList2String(alParameters,0)·;
········state·reading·;
····}
}

//·States
default
{
····on_rez(integer·aiStartParameter)
····{
········reset()·;
····}
····
····changed(integer·aiChange)
····{
········if((aiChange·&·CHANGED_OWNER)·||·(aiChange·&·CHANGED_INVENTORY))
········{
············reset()·;
········}
····}

····state_entry()·
····{
········llListen(CHANNEL_NUM,·"",·NULL_KEY·,·"";)·;
····}

····listen(integer·aiChannel,·string·asName,·key·akId,·string·asMessage)
····{
········if(aiChannel==·CHANNEL_NUM)
········{
············list·lMessage·=·llParseString2List(asMessage,["·"],[""])·;
············integer·iLength·=·llGetListLength(lMessage);
············if·(iLength·>·0)
············{
················string·sCommand·=·(string)llList2String(lMessage,0)·;
················if·(~llListFindList(VALID_COMMANDS,·(list)sCommand))
················{
····················lMessage·=·llDeleteSubList(lMessage,·0,·0)·;
····················doIt(sCommand,·lMessage)·;
················}
················else
················{
····················llOwnerSay("Invalid·command·'"·+·sCommand·+·"'"·)·;
················}
············}
············else
············{
················llOwnerSay("Message'"·+·asMessage·+·"'·contains·no·command"·)·;
············}
········}
····}
}

state·reading
{
····state_entry()
····{
········if·(checkCard(gsNotecardName))
········{
············gkNotecardRequest·=·llGetNumberOfNotecardLines(gsNotecardName)·;
············llSetTimerEvent(5.0)·;
········}
········else
········{
············llOwnerSay("Notecard·'"·+·gsNotecardName·+·"'·does·not·exist";)·;
········}
····}

····timer()
····{
········llSetTimerEvent(0.0)·;
········llOwnerSay("Notecard·'"·+·gsNotecardName·+·"'·is·probably·empty";)·;
········state·default;
····}

····dataserver(key·akQueryId,·string·asData)
····{
········if·(akQueryId·==·gkNotecardRequest·)
········{
············llSetTimerEvent(0.0)·;
············if·(asData·==·EOF)·
············{
················showCard()·;
················state·default·;
············}
············else·if·(giNumNotecardLines·==·0)·
············{
················giNumNotecardLines·=·(integer)asData·;
················gkNotecardRequest·=·llGetNotecardLine(gsNotecardName,·giNotecardLine)·;
············}
············else
············{
················glCardData··=·glCardData··+[asData]·;
················++giNotecardLine·;
················gkNotecardRequest·=·llGetNotecardLine(gsNotecardName,·giNotecardLine)·;
············}
········}
····}
}
Eadoin Welles
Registered User
Join date: 5 Jan 2007
Posts: 149
11-07-2007 03:23
USAGE

Synopsys

/101 reset
/101 say anytext
/101 show cardname

RESET just reset the script and remove hovertext
SAY just show as hovertext what you said
SHOW shows the content of a notecard in the object inventory, if any

Examples

/101 say Questa è una bella giornata!

/101 show chinese

where chinese notecard contains

简体中文
第一批异体字整理表

/101 show russian

where russian notecard contains

Финно-угорский субстрат в русском языке:
Учебное пособие по спецкурсу
Masakazu Kojima
ケロ
Join date: 23 Apr 2004
Posts: 232
11-07-2007 15:42
From: Eadoin Welles
Just copy and paste to an editor, and change all occurrences of "·" to " ":

That's pretty clever -- SL actually ignores unrecognized characters so you don't really even need to change it. Well, except to fix the spaces the forums insert at like 78 characters, and you're missing an "if" on the first line of doIt().