Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Discussion: URL Loader

Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
04-06-2005 11:40
I made this to read a notecard called 'bookmarks' so you can click on a prim and it will direct you to the right place. It also uses hover text to show what it's looking at.

[PHP code]
string card="bookmarks";
integer i=0;
integer pointer=0;
list URLs;
list Hover;
key owner;
integer listenID;

default
{
state_entry()
{
llSetText("Loading bookmarks", <1,1,1>, 1.0);
llGetNotecardLine(card, i);
owner=llGetOwner();
}
touch_start(integer times)
{
key who=llDetectedKey(0);
if(who==owner)
{
llDialog(owner, "Open URL or select new target?", ["Open", "Prev", "Next"], 1001);
listenID=llListen(1001, "", owner, "";);
} else {
llLoadURL(llDetectedKey(0), "Load "+llList2String(Hover, pointer), llList2String(URLs, pointer));
}
}
dataserver(key query, string data)
{
if(data!=EOF)
{
list temp=llCSV2List(data);
Hover+=llList2String(temp, 0);
URLs+=llList2String(temp, 1);
i++;
llGetNotecardLine(card, i);
} else {
llSetText(llList2String(Hover, pointer), <1,1,1>, 1.0);
}
}
listen(integer channel, string name, key ID, string message)
{
llSetTimerEvent(60);
if(message=="Open";)
{
llLoadURL(llGetOwner(), "Load "+llList2String(Hover, pointer), llList2String(URLs, pointer));
} else if(message=="Prev";)
{
pointer++;
if(pointer==llGetListLength(Hover))
{
pointer=0;
}
} else if(message=="Next";)
{
pointer--;
if(pointer<0)
{
pointer=llGetListLength(Hover);
pointer--;
}
}
llSetText(llList2String(Hover, pointer), <1,1,1>, 1.0);
llListenRemove(listenID);
}
changed(integer change)
{
if(change && CHANGED_INVENTORY)
{
llResetScript();
}
}
timer()
{
llListenRemove(listenID);
}
}
[/PHP code]

You need a notecard with the description then the full URL, separated by commas, one per line in there too, that's it!
Nada Epoch
The Librarian
Join date: 4 Nov 2002
Posts: 1,423
Original Thread:
04-08-2005 13:15
/15/e0/41737/1.html
_____________________
i've got nothing. ;)
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
04-08-2005 14:30
There are a couple little issue with the code. If spam clicked by the owner it will leak it's listens. Eventualy running out of listens and crashing.
CODE
//...
llDialog(owner, "Open URL or select new target?", ["Open", "Prev", "Next"], 1001);
listenID=llListen(1001, "", owner, "");

Should be this
CODE
//...
llDialog(owner, "Open URL or select new target?", ["Open", "Prev", "Next"], 1001);
llListenRemove(listenID);
listenID=llListen(1001, "", owner, "");



Not the logic that was intended.
CODE
//...
if(change && CHANGED_INVENTORY)

should be...
CODE
//...
if(change & CHANGED_INVENTORY)




CODE

string card="bookmarks";
integer i=0;
integer pointer=0;
list URLs;
list Hover;
key owner;
integer listenID;

default
{
state_entry()
{
llSetText("Loading bookmarks", <1,1,1>, 1.0);
llGetNotecardLine(card, i);
owner=llGetOwner();
}
touch_start(integer times)
{
key who=llDetectedKey(0);
if(who==owner)
{
llDialog(owner, "Open URL or select new target?", ["Open", "Prev", "Next"], 1001);
llListenRemove(listenID);
listenID=llListen(1001, "", owner, "");
} else {
llLoadURL(llDetectedKey(0), "Load "+llList2String(Hover, pointer), llList2String(URLs, pointer));
}
}
dataserver(key query, string data)
{
if(data!=EOF)
{
list temp=llCSV2List(data);
Hover+=llList2String(temp, 0);
URLs+=llList2String(temp, 1);
i++;
llGetNotecardLine(card, i);
} else {
llSetText(llList2String(Hover, pointer), <1,1,1>, 1.0);
}
}
listen(integer channel, string name, key ID, string message)
{
llSetTimerEvent(60);
if(message=="Open")
{
llLoadURL(llGetOwner(), "Load "+llList2String(Hover, pointer), llList2String(URLs, pointer));
} else if(message=="Prev")
{
pointer++;
if(pointer==llGetListLength(Hover))
{
pointer=0;
}
} else if(message=="Next")
{
pointer--;
if(pointer<0)
{
pointer=llGetListLength(Hover);
pointer--;
}
}
llSetText(llList2String(Hover, pointer), <1,1,1>, 1.0);
llListenRemove(listenID);
}
changed(integer change)
{
if(change & CHANGED_INVENTORY)
{
llResetScript();
}
}
timer()
{
llListenRemove(listenID);
}
}
_____________________
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
Lightwave Valkyrie
Registered User
Join date: 30 Jan 2004
Posts: 666
04-11-2005 16:58
thanks this works great!
i made a webportal object from the show ReBoot
and added this script.
-LW
Csven Concord
*
Join date: 19 Mar 2005
Posts: 1,015
04-11-2005 18:44
works well. thank you.