Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

llGetNotecardLine()

Attis Box
Registered User
Join date: 18 Jan 2007
Posts: 6
04-11-2007 18:23
Hello,

Can I access two different lines of a notecard in the same script?

What I want to do is use a notecard to refer to radio stations, first line being the stream URL and second line being description.

I want to use llSetParcelMusicURL to refer to first line, and
llSetText to display description above prim, using second line of notecard.

Then I use touch_start to change lines on notecard to change stations.

I have the script working to change stations and display URL, but I can't seem to get script to use access both lines at once.

Here's the code so far:

CODE
string gStream; // name of notecard in the object's inventory
integer gURL = 0; // current line number
key gQueryID; // id used to identify dataserver queries

default
{
state_entry()
{
gStream = llGetInventoryName(INVENTORY_NOTECARD, 0);
gQueryID = llGetNotecardLine(gStream, gURL); // request first line

}
touch_start(integer num_detected)
{
state start;
}

dataserver(key query_id, string data)
{
if (query_id == gQueryID )
{
if (data != EOF) // not at the end of the notecard
{
llSetParcelMusicURL(data);
llSetText(data, <1,1,1>,1);
gQueryID = llGetNotecardLine(gStream, gURL);
}
}
}
}


state start
{
state_entry()
{
gStream = llGetInventoryName(INVENTORY_NOTECARD, 0);
gQueryID = llGetNotecardLine(gStream, gURL);
}

touch_start(integer num_detected)
{
state default;
}
dataserver(key query_id, string data)
{
if (data != EOF)
{
++gURL; //switch to next line in notecard
++gURL; //this second is to skip URL description line
}
else
{
llResetScript();
}
}
}


Also, I've noticed that with this script, it requires two touches to change station. I think I know why, but I don't know how to fix that either.

Any advice is appreciated.
DoteDote Edison
Thinks Too Much
Join date: 6 Jun 2004
Posts: 790
04-11-2007 19:08
It would be better to use a single line with a separator ("~", "|", etc) between the two pieces of data. Then, one line read would produce both values. Parse the data returned using llParseString2List(). Then, use llList2String() to convert from the list into your llSetParcelMusicURL() & llSetText() functions.

However, yes you can read a second line automatically... simply read the next notecard line by calling: gQueryID = llGetNotecardLine(gStream, ++gURL) again, at the end of your dataserver event. If gURL is the notecard line (0), then ++gURL will read noteacard line 1.
Attis Box
Registered User
Join date: 18 Jan 2007
Posts: 6
Thanks
04-18-2007 19:39
Thanks for your help...

You pointed me in the right direction and I was able to get it working.
I had trouble finding this post again, or I would have thanked you sooner.