CardReader
Load a
notecard into a
list.
Lists are not always the best option for this. However, if the notecard is small, this will save a lot of pain. Hopefully the example can save some confusion over reading card data.
It's probably better the use a finished reading state
string gReadCardName; // notecard name for readCard state
integer gReadCardLine; // global counter for card reader
list gReadCardData = []; //loaded by call
integer gCardRead = FALSE; //use a read completed state and this can be done away with
DumpData(list srcList) {
integer i;
integer j = llGetListLength( srcList );
for( i=0; i<j; i++ ) {
string item = llList2String(srcList, i);
llOwnerSay((string)i + ": " + item);
}
}
default {
state_entry() {
if (!gCardRead) {
llOwnerSay("Touch to Test");
} else {
DumpData(gReadCardData);
}
}
touch_start(integer total_number) {
gReadCardName = "notes1";
state readCard;
}
}
state readCard {
state_entry() {
gReadCardData = [];
gReadCardLine = 0;
llGetNotecardLine(gReadCardName, gReadCardLine);
}
dataserver(key query_id, string data) {
// we are in our isolated state here, we don't need to track the query_id
if (data != EOF) {
gReadCardData += data;
gReadCardLine++;
llGetNotecardLine(gReadCardName, gReadCardLine);
} else {
gCardRead = TRUE;
state default;
}
}
}
ScriptLibrary |
Dolyn's Scripts