Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Using Notecard to Trigger Webpage

beatphreak Voom
Registered User
Join date: 2 May 2007
Posts: 4
04-22-2008 07:39
I have a script that uses a notecard to get a name to say and a webpage to display.

Every thing works fine, names are said, objects are rezzed and the webpage gets triggered.

The problem is the webpage triggers twice...any ideas?

CODE

// Read out a complete notecard from the object's inventory.
string gName; // name of a notecard in the object's inventory
integer gLine = 0; // current line number
key gQueryID; // id used to identify dataserver queries
string gElement; //name to use from notecard
string gWeb; //webaddress to use
key Agent; //Avatar to give notecard to
integer gInventoryNum; //How many objects in inventory
integer gRezNum; //Which object to rez



default {
on_rez(integer start_param)
{
llResetScript(); //just to be safe

}




touch_start(integer num_detected)
{
gInventoryNum=0;
gRezNum = 0;

gName = llGetInventoryName(INVENTORY_NOTECARD, 0); // select the first notecard in the object's inventory
gQueryID = llGetNotecardLine(gName, gLine); // request first line
Agent = llDetectedKey(0);
gInventoryNum = llGetInventoryNumber(INVENTORY_OBJECT);

llRegionSay(-95436,"Die"); //Kill any rezzed objects
llGiveInventory(llDetectedKey(0), gName); //Give out the notecard

//A loop to rez the inventory objects
do
{

llRezObject(llGetInventoryName(INVENTORY_OBJECT,gRezNum), llGetRootPosition(), <0,0,0>,<-0.00000, 1.00000, 0.00000, 0.00000> * llGetRot(), 42);

++gRezNum; //step through inventory objects

}
while (gRezNum < gInventoryNum); //Get to end of inventory and stop
}

// Get info from notecard

dataserver(key query_id, string data) {
if (query_id == gQueryID) {
if (gLine <= 1) {
if (gLine == 0) //First line
{

gElement = data; // output the line to gElement
++gLine; // increase line count
gQueryID = llGetNotecardLine(gName, gLine); // request next line
}

if (gLine == 1) //Second Line
{
gWeb = data; //output the line to gWeb
}

llSay(-95435, gElement); //Say name for xy text display
llLoadURL(Agent, gElement, gWeb); //Trigger webpage

}
}
}
}
Viktoria Dovgal
Join date: 29 Jul 2007
Posts: 3,593
04-22-2008 08:19
From: beatphreak Voom
The problem is the webpage triggers twice...any ideas?

Looks like you want your llLoadURL() inside that "if (gLine == 1)" block instead of after.
_____________________
Django Yifu
Beat Island Gaffer
Join date: 7 May 2007
Posts: 189
04-24-2008 13:34
Hmmm not sure.. I shall give that a go although I'm not sure why it would make it create two calls to the web page.

****Edit****

Just tried the suggestion above and it made no difference in terms of whether the LoadURL happens twice...

It seems that sometimes it works fine but more often than not it calls the webpage twice.

****Edit 2****

This seems to have been the culprit

CODE

// Read out a complete notecard from the object's inventory.
string gName; // name of a notecard in the object's inventory
integer gLine = 0; // current line number

//rest of code.............

dataserver(key query_id, string data) {
if (query_id == gQueryID) {
if (gLine <= 1) {
if (gLine == 0)
{

//rest of code.............



making the following change allows it to work

CODE

// Read out a complete notecard from the object's inventory.
string gName; // name of a notecard in the object's inventory
integer gLine; // current line number **changed

//rest of code.............

touch_start(integer num_detected)
{
gLine = 0; //**changed

//rest of code.............

dataserver(key query_id, string data) {
if (query_id == gQueryID) {
if (gLine <= 0) { //**changed
if (gLine == 0)
{

//rest of code.............

_____________________
Tread softly upon the Earth for you walk on my face.
Ordinal Malaprop
really very ordinary
Join date: 9 Sep 2005
Posts: 4,607
04-24-2008 13:56
Bah, I was just typing my explanation of how you had not reset gLine, but it seems you have solved it, good show.
_____________________
http://ordinalmalaprop.com/forum/ - visit Ordinal's Scripting Colloquium for scripting discussion with actual working BBCode!

http://ordinalmalaprop.com/engine/ - An Engine Fit For My Proceeding, my Aethernet Journal

http://www.flickr.com/groups/slgriefbuild/ - Second Life Griefbuild Digest, pictures of horrible ad griefing and land spam, and the naming of names