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.