Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

An SL Bug? llGetNoteCardLine gives notecard key?

Over Sleeper
I Dream in LSL
Join date: 12 Jan 2006
Posts: 141
07-05-2006 11:45
Shouldn't this output a string...like whatever is on the first line of the notecard?

CODE

string MyNotecardLine= llGetNotecardLine("testNotecard", 0);
llWhisper(0,MyNotecardLine);


It doesn't...it outputs the key of the notecard instead. llGetNoteCardLine isn't supposed to give the key of the notecard is it?
Xixao Dannunzio
Owner, X3D Enterprises
Join date: 20 Mar 2006
Posts: 114
07-05-2006 12:18
You need to use a dataserver event.

http://secondlife.com/badgeo/wakka.php?wakka=llGetNotecardLine
Adrian Zobel
Registered User
Join date: 4 Jan 2006
Posts: 49
07-05-2006 12:19
The function is supposed to return a key.
The actual data from the notecard is returned in a dataserver event with a queryid that matches the returned key.
http://secondlife.com/badgeo/wakka.php?wakka=llGetNotecardLine
Over Sleeper
I Dream in LSL
Join date: 12 Jan 2006
Posts: 141
07-05-2006 12:31
How can I make it loop through the lines of a notecard and whisper each one?
Xixao Dannunzio
Owner, X3D Enterprises
Join date: 20 Mar 2006
Posts: 114
07-05-2006 12:35
From the link we just gave (modified for whisper):

CODE
string gName = "Testnotecard";    // name of a notecard in the object's inventory
integer gLine = 0; // current line number
key gQueryID; // id used to identify dataserver queries

default {
state_entry() {
gQueryID = llGetNotecardLine(gName, gLine); // request first line
}

dataserver(key query_id, string data) {
if (query_id == gQueryID) {
if (data != EOF) { // not at the end of the notecard
llWhisper(0, (string)gLine+": "+data); // output the line
++gLine; // increase line count
gQueryID = llGetNotecardLine(gName, gLine); // request next line
}
}
}
}
Over Sleeper
I Dream in LSL
Join date: 12 Jan 2006
Posts: 141
07-05-2006 12:43
Using that example, it only whispers the first line:

Object whispers: 0: Aaah Chu
Xixao Dannunzio
Owner, X3D Enterprises
Join date: 20 Mar 2006
Posts: 114
07-05-2006 12:46
CODE
++gLine;                // increase line count
gQueryID = llGetNotecardLine(gName, gLine); // request next line


Did you copy it correctly?

++gLine adds 1 to the line number that is being read.
gQueryID = llGetNotecardLine(gName, gLine) runs the dataserver event again.

You should not be having this problem.


.: EDIT :.
Also note that the dataserver event is called in state_entry().

If you update if after that, the script needs a reset to see the changes.

Alternatively, you could use:

(Touch event)
CODE
 string gName = "Testnotecard";    // name of a notecard in the object's inventory
integer gLine = 0; // current line number
key gQueryID; // id used to identify dataserver queries

default {
touch_start(integer num_detected) {
gLine = 0;
gQueryID = llGetNotecardLine(gName, gLine); // request first line
}

dataserver(key query_id, string data) {
if (query_id == gQueryID) {
if (data != EOF) { // not at the end of the notecard
llWhisper(0, (string)gLine+": "+data); // output the line
++gLine; // increase line count
gQueryID = llGetNotecardLine(gName, gLine); // request next line
}
}
}
}



Or:

(As notecard is updated)
CODE
 string gName = "Testnotecard";    // name of a notecard in the object's inventory
integer gLine = 0; // current line number
key gQueryID; // id used to identify dataserver queries

default {
state_entry() {
gQueryID = llGetNotecardLine(gName, gLine); // request first line
}

dataserver(key query_id, string data) {
if (query_id == gQueryID) {
if (data != EOF) { // not at the end of the notecard
llWhisper(0, (string)gLine+": "+data); // output the line
++gLine; // increase line count
gQueryID = llGetNotecardLine(gName, gLine); // request next line
}
}
}

changed(integer change) { // something changed
if (change & CHANGED_INVENTORY) { // inventory (notecard) changed
gLine = 0;
gQueryID = llGetNotecardLine(gName, gLine); // read notecard again
}
}
}