Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Libary: Dynamic Unicode Hovertext

Eadoin Welles
Registered User
Join date: 5 Jan 2007
Posts: 149
11-07-2007 03:15
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)·;
············}
········}
····}
}
Nada Epoch
The Librarian
Join date: 4 Nov 2002
Posts: 1,423
11-11-2007 12:34
To reiterate:
For the script to work, copy and paste to an editor, and change all occurrences of "·" to " "
_____________________
i've got nothing. ;)
Abba Thiebaud
PerPetUal NoOb
Join date: 20 Aug 2006
Posts: 563
11-11-2007 14:27
The formatting has to be manually done because of the llSetText commands, license information, etc., otherwise, you have to manually format it anyways when you get done in your editor.

A
_____________________
http://www.ponystars.com/abbathiebaud Pony Up.
Case Schnabel
Registered User
Join date: 12 Jan 2007
Posts: 2
11-18-2007 03:35
it gives me a syntax error on line 58. I'm no scripter so I ask your help.
Teves Decosta
Registered User
Join date: 7 Sep 2007
Posts: 2
11-20-2007 03:35
The error is that the code is not completed:

Code correct:

...

doIt(string asCommand, list alParameters)
{
if (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 ;
}
}

...

Best regards
Case Schnabel
Registered User
Join date: 12 Jan 2007
Posts: 2
11-29-2007 19:09
thanks a lot - working! ;)
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
11-29-2007 19:47
Between having to remove the dots, find & remove the extra spaces and add in the if, it may end up getting confusing real fast for the newer people.

I took the liberty of attaching a text file with the script corrected and formatted. Anyone can just open it, select all and paste into a script for it to work.
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
11-29-2007 22:33
You can use any of these characters instead of spaces and the compiler will treat them as spaces (as long as they aren't in strings): #$'?`
_____________________
Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river.
- Cyril Connolly

Without the political will to find common ground, the continual friction of tactic and counter tactic, only creates suspicion and hatred and vengeance, and perpetuates the cycle of violence.
- James Nachtwey
Nadir Taov
role-player
Join date: 13 Dec 2006
Posts: 26
12-15-2007 13:47
thanks! This helped me a lot :)
Sarah Showboat
Registered User
Join date: 3 Nov 2006
Posts: 13
hearts
12-16-2007 11:06
How do they display hearts and other characters in hovertext? I looks like old ASCII chars, but i don't see anywhere on the LSL wiki that refers to ASCII.

Much thanks,
Zeph Twine
Registered User
Join date: 24 Jul 2008
Posts: 2
?
12-14-2008 18:35
um, yea, not too sure how to get this to work after its in an object, any help?