Jump to content

Dataserver issue


2toe Bigboots
 Share

You are about to reply to a thread that has been inactive for 4411 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

okay so i want to put a message on notecards (as many as i feel ) and youch button to open textbox say name of note card (named for my mesg) it says name. root then finds and reads it on 0.  but i cant seem to figure how to make it query what was said in chat

 

Link to comment
Share on other sites

You can start the dataserver going with something like this:

key query;integer counter;string notecard;///	listen(integer channel, string name, key id, string message)	{		if(llGetInventoryType(message)==INVENTORY_NOTECARD){			counter = 0;			notecard = message;			query = llGetNotecardLine(notecard,counter);		}	}////}

 ETA Darkie beat me to it.

Link to comment
Share on other sites

Well i know its messy havent even started to clean up lol  but ya idk this dont seem to work like i want. i say /-999 test

and it shouts a key for the notecard. and error can not find notecard'

 

string gName;    // name of a notecard in the object's inventoryinteger gLine = 0;list cards = [];//key rQueryID;key query_id;integer counter;string notecard; string said;key gQueryID; // id used to identify dataserver queriesdefault {    state_entry() {        llListen(-999,"","","");        gName = llGetInventoryName(INVENTORY_NOTECARD, 0); // select the first notecard in the object's inventory        gQueryID = llGetNotecardLine(gName, gLine);    // request first line    }    listen(integer channel, string name, key id, string message)    {        if(llGetInventoryType(message)==INVENTORY_NOTECARD){            counter = 0;            notecard = message;            query_id = llGetNotecardLine(notecard,counter);            said = llGetNotecardLine(llKey2Name(notecard),counter);            llShout(0,said);        }    }    dataserver(key query_id, string data) {        if (query_id == gQueryID) {            if (data != EOF) {    // not at the end of the notecard                llSay(0, (string)gLine+": "+data);    // output the line                ++gLine;                // increase line count                gQueryID = llGetNotecardLine(gName, gLine);    // request next line            }        }    }}

 

Link to comment
Share on other sites

See my comments and changes below

string gName;    // name of a notecard in the object's inventoryinteger gLine = 0;list cards = [];//key rQueryID;key query_id;integer counter;string notecard; string said;key gQueryID; // id used to identify dataserver queriesdefault {    state_entry() {        llListen(999,"","",""); //Darkie: if you say something in the chat, you can't use a negative channel        gName = llGetInventoryName(INVENTORY_NOTECARD, 0); // select the first notecard in the object's inventory        gQueryID = llGetNotecardLine(gName, gLine);    // request first line    }    listen(integer channel, string name, key id, string message)    {        if(llGetInventoryType(message)==INVENTORY_NOTECARD){            gLine = 0;//Darkie: use gLine here again            notecard = message;            gQueryID = llGetNotecardLine(notecard,gLine);//Darkie: use gLine here again; you need the variable gQueryID            //said = llGetNotecardLine(llKey2Name(notecard),gLine); //Darkie: this doesn't really make sense; what do you want to get here?            //llShout(0,said);        }    }    dataserver(key query_id, string data) {        if (query_id == gQueryID) {            if (data != EOF) {    // not at the end of the notecard                llSay(0, (string)gLine+": "+data);    // output the line                ++gLine;                // increase line count                gQueryID = llGetNotecardLine(gName, gLine);    // request next line            }        }    }}

 

Link to comment
Share on other sites

No.  The key returned by llGetNoteCardLine identifies the dataserver response.   So, in the dataserver event you do something like:

dataserver(key requested, string data){	if(requested == query){//make sure it's what we requested		if(data!=EOF){//if it's not come to the end of the card			data = llStringTrim(data,STRING_TRIM);//trim leading and trailing spaces			if(data!=""){// if there's anything left -- i.e. it's not an empty line				llOwnerSay(data);//process it some way			}			counter++;//advance the counter			query = llGetNotecardLine(notecard,counter);//fetch the next line		}		else{			llOwnerSay("Reached the end of the card");		}	}}

 

Link to comment
Share on other sites

Forgot gName once again ;)

string gName;    // name of a notecard in the object's inventoryinteger gLine = 0;list cards = [];//key rQueryID;//key query_id; //Darkie: as has been saidinteger counter;string notecard; string said;key gQueryID; // id used to identify dataserver queriesdefault {    state_entry() {        llListen(999,"","",""); //Darkie: if you say something in the chat, you can't use a negative channel        gName = llGetInventoryName(INVENTORY_NOTECARD, 0); // select the first notecard in the object's inventory        gQueryID = llGetNotecardLine(gName, gLine);    // request first line    }    listen(integer channel, string name, key id, string message)    {        if(llGetInventoryType(message)==INVENTORY_NOTECARD){            gLine = 0;//Darkie: use gLine here again            gName = message; //Darkie: put gName here            gQueryID = llGetNotecardLine(gName,gLine);//Darkie: use gLine here again; you need the variable gQueryID; use gName here            //said = llGetNotecardLine(llKey2Name(notecard),gLine); //Darkie: this doesn't really make sense; what do you want to get here?            //llShout(0,said);        }    }    dataserver(key query_id, string data) {        if (query_id == gQueryID) {            if (data != EOF) {    // not at the end of the notecard                llSay(0, (string)gLine+": "+data);    // output the line                ++gLine;                // increase line count                gQueryID = llGetNotecardLine(gName, gLine);    // request next line            }        }    }}

Read up on the dataserver event and llGetNotecardLine 

  • Like 1
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 4411 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...