02-02-2007 19:39
This is a simple script that will return the number of words in the first notecard object in inventory.

Drop a notecard into the container prim, then touch.



CODE

string sNote = "";
integer nLine = 0;
key queryID = NULL_KEY;
integer nCount = 0;

default
{
state_entry()
{
llAllowInventoryDrop(TRUE);
}

on_rez(integer start_param)
{
llResetScript();
}

touch_start(integer total_number)
{
sNote = llGetInventoryName(INVENTORY_NOTECARD, 0);
if(sNote != "") {
queryID = llGetNotecardLine(sNote, 0);
}
}

dataserver(key query_id, string data)
{
if(query_id == queryID) {
if(data != EOF) {
nCount = nCount + llGetListLength(llParseString2List(data, [" "], []));
nLine++;
queryID = llGetNotecardLine(sNote, nLine);
} else {
llSay(0, "Notecard " + sNote + " contains " + (string)nCount + " words.");
}
}
}
}