Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Discussion: Chat-URL-Tracker

Cockerel Mommsen
Registered User
Join date: 28 Feb 2006
Posts: 3
06-08-2006 18:55
The following code makes it easier to open URLs beginning with "http://" said on channel 0 by anyone (no more need to open History and then ctrl-c, ctrl-v)

No big thing but as i think quite handy.

Just put it into a prim and attach it to your hud.
If you touch the (invisible) prim (it's below the text saying "Last URL";) the text will appear/disappear for taking screenshots.

CODE

list glMessageParts;
string gsHoverText = "Last URL:";
integer giTextShow = TRUE;
default
{
state_entry()
{
llListen(0,"",NULL_KEY,"");
llSetAlpha(0,ALL_SIDES);
llSetText(gsHoverText,<1,1,1>,1);
}

touch_start(integer num) // switch hovertext on and off
{
if (giTextShow)
{
giTextShow = FALSE;
llSetText("",<1,1,1>,1);
} else {
giTextShow = TRUE;
llSetText(gsHoverText,<1,1,1>,1);
}

}

listen(integer channel, string name, key id, string message)
{
glMessageParts = llParseString2List(message, [" "], []);
integer i;
for(i=0; i<llGetListLength(glMessageParts); i++)
{
if (llGetSubString(llList2String(glMessageParts, i), 0,6) == "http://") //check for valid URL
{
gsHoverText = "Last URL:\n" + llList2String(glMessageParts, i);
llSetText(gsHoverText, <1,1,1>, 1);
llLoadURL(llGetOwner(), llGetSubString(llList2String(glMessageParts, i), 7,-1), llList2String(glMessageParts, i));

}
}
}
}
Nada Epoch
The Librarian
Join date: 4 Nov 2002
Posts: 1,423
Original Thread
06-08-2006 21:06
/15/ea/112675/1.html
_____________________
i've got nothing. ;)
Ima Mechanique
Registered User
Join date: 25 Feb 2005
Posts: 23
06-10-2006 12:13
Do we really need anymore open Listens on channel 0 to contribute to server lag.
Keknehv Psaltery
Hacker
Join date: 11 Apr 2005
Posts: 1,185
06-10-2006 13:41
From: Ima Mechanique
Do we really need anymore open Listens on channel 0 to contribute to server lag.

Usually questions end with a question mark in English.

Meh, listens aren't that bad for the sim, if it's just one object. When it's 30 poseballs, then you can complain.
Escort DeFarge
Together
Join date: 18 Nov 2004
Posts: 681
06-10-2006 16:31
I beg to differ - opening an open listen on channel 0 is *always* a bad idea.
_____________________
http://slurl.com/secondlife/Together
Ima Mechanique
Registered User
Join date: 25 Feb 2005
Posts: 23
06-10-2006 16:33
From: Keknehv Psaltery
When it's 30 poseballs, then you can complain.


I disagree, the time to complain is at the root of the problem. Each open channel 0 Listen contributes to the problem. When 30 people with this script are in a sim it will have a worse effect than the pose balls, because they usually have a limitiation, even if it's only 'show' and 'hide' for the commands. This script listens to absolutely everything.

As for pose balls, I wouldn't miss them if they vanished over night. But nobody said anything when the first one was produced, so we're stuck with them.
Cockerel Mommsen
Registered User
Join date: 28 Feb 2006
Posts: 3
06-12-2006 16:27
you're right...
it might produce lag... ;)

still it's handy - just wanted to share my idea - maybe i should'nt have done so :S ??
Keknehv Psaltery
Hacker
Join date: 11 Apr 2005
Posts: 1,185
06-12-2006 16:39
Meh, don't worry. I don't think a few people walking around with these will seriously harm anything; it's not as if everyone's going to have a Chat-URL-Tracker. A minor amount of lag is acceptable for a feature that should probably be included in the client anyways.
Angel Fluffy
Very Helpful
Join date: 3 Mar 2006
Posts: 810
06-13-2006 03:11
Better idea : get the SL client (NOT THE SERVER) to parse chat messages and save URLs for you in a seperate window. Parsing chat messages is something the client can do fairly fast (I'd hope) and so wouldn't create a lot of lag, I'd hope.
Yiffy Yaffle
Purple SpiritWolf Mystic
Join date: 22 Oct 2004
Posts: 2,802
06-15-2006 11:58
I found this to be a great idea and very helpful. i also learned something from this bit of code. I usually use llGetListLength but never knew how to get it to decipher a word from the middle of a sentence like that. :)
_____________________
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
06-15-2006 12:13
if you want the code to be faster, try
CODE

string gsHoverText = "Last URL:";
integer giTextShow = TRUE;
default
{
state_entry()
{
llListen(0,"",NULL_KEY,"");
llSetAlpha(0,ALL_SIDES);
llSetText(gsHoverText,<1.0,1.0,1.0>,1.0);
}

touch_start(integer num) // switch hovertext on and off
{
if (giTextShow)
{
giTextShow = FALSE;
llSetText("",<1.0,1.0,1.0>,1.0);
} else {
giTextShow = TRUE;
llSetText(gsHoverText,<1.0,1.0,1.0>,1.0);
}
}

listen(integer channel, string name, key id, string message)
{
list glMessageParts = llParseString2List(message, [" "], []);
integer i = -llGetListLength(glMessageParts);
do
{
string this = llList2String(glMessageParts, i);
if (llGetSubString(this, 0,6) == "http://") //check for valid URL
{
gsHoverText = "Last URL:\n" + this;
if(giTextShow)
llSetText(gsHoverText, <1.0,1.0,1.0>, 1.0);
if(llGetAgentInfo(llGetOwner())
llLoadURL(llGetOwner(), llGetSubString(this, 7,-1), this);
}
}while(++i);
}
}
_____________________
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
Talarus Luan
Ancient Archaean Dragon
Join date: 18 Mar 2006
Posts: 4,831
06-15-2006 12:53
Just a minor suggestion, Strife..

When you post a more optimized vesion of someone's script, would you mind also describing what changes you made and why? I think I understand some of the changes you make, though some of the rationale escapes me. I can imagine there are quite a few folks who would benefit from your scripting wisdom, and I think it would also help everyone overall to have more efficient scripts running and not lagging the sims. :)

Thanks for you consideration. :)
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
06-16-2006 10:06
The major thing i changed was from using positive list indexes to negitive; the reason for this was to remove the "i < llGetListLength". Each time the script loops llGetListLength is called, which requires duplicating the entire list in memory. Which is slow. A condition is true if it is non zero. llParseString2List cannot return a null list. So we set it to the list length and make it negitive, we have the negitive index of the last number. Now we just have to loop though the list till we run out of negitive indexes or when "i" equals zero. Another advantage of using this menthod is that a Do While loop is faster then a regular while loop.

The next change was using a string to temporarily store the value. This saves us from having to look it up from the list (which duplicates the list in memory).

If you want to shave a bit more off...
replace
CODE

string this = llList2String(glMessageParts, i);
if (llGetSubString(this, 0,6) == "http://") //check for valid URL
{
gsHoverText = "Last URL:\n" + this;
if(giTextShow)
llSetText(gsHoverText, <1.0,1.0,1.0>, 1.0);
if(llGetAgentInfo(llGetOwner())
llLoadURL(llGetOwner(), llGetSubString(this, 7,-1), this);
}

with
CODE

if (llGetSubString(message = llList2String(glMessageParts, i), 0,6) == "http://") //check for valid URL
{
gsHoverText = "Last URL:\n" + message ;
if(giTextShow)
llSetText(gsHoverText, <1.0,1.0,1.0>, 1.0);
if(llGetAgentInfo(llGetOwner())
llLoadURL(llGetOwner(), llDeleteSubString(message, 0,6), message);
}

this saves a bit on bitecode and memory. Should be a bit faster.
_____________________
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