2toe Bigboots Posted April 3, 2012 Share Posted April 3, 2012 Hello im trying to have a notecard read but i want it to be based off what what said in chat or linkmessage. Ive tried a few things but keep gerring errors. any tips on this? Or use a menu to list notecards in inventory and send choise that way Link to comment Share on other sites More sharing options...
Darkie Minotaur Posted April 3, 2012 Share Posted April 3, 2012 could you be a bit more specific? Link to comment Share on other sites More sharing options...
2toe Bigboots Posted April 3, 2012 Author Share Posted April 3, 2012 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 More sharing options...
Darkie Minotaur Posted April 3, 2012 Share Posted April 3, 2012 this would get you the first line of the notecard named like the text box input listen(integer channel, string name, key id, string message) { llGetNotecardLine(message, 0);} Link to comment Share on other sites More sharing options...
Innula Zenovka Posted April 3, 2012 Share Posted April 3, 2012 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 More sharing options...
2toe Bigboots Posted April 3, 2012 Author Share Posted April 3, 2012 so that will relay the notecards key right, Link to comment Share on other sites More sharing options...
2toe Bigboots Posted April 3, 2012 Author Share Posted April 3, 2012 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 More sharing options...
Darkie Minotaur Posted April 3, 2012 Share Posted April 3, 2012 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 More sharing options...
Innula Zenovka Posted April 3, 2012 Share Posted April 3, 2012 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 More sharing options...
Qie Niangao Posted April 3, 2012 Share Posted April 3, 2012 I'd also suggest removing the global variable, query_id. It's only going to cause confusion with the locally scoped query_id parameter of the dataserver event handler. Link to comment Share on other sites More sharing options...
2toe Bigboots Posted April 3, 2012 Author Share Posted April 3, 2012 okay so 1st darkie that worked as far as reading one line how do i make it read a hole card ive seen stuff like for(i =0; i < llGetNumberOfNotecardLines(gName); but not sure how to adaped it to what in doing Link to comment Share on other sites More sharing options...
Darkie Minotaur Posted April 3, 2012 Share Posted April 3, 2012 I missed that line: notecard = message; In the listen event should be gName = message; Link to comment Share on other sites More sharing options...
2toe Bigboots Posted April 3, 2012 Author Share Posted April 3, 2012 Could not find notecard when i make that change. if i leave it it llsay the 1st line only. Link to comment Share on other sites More sharing options...
Darkie Minotaur Posted April 3, 2012 Share Posted April 3, 2012 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 1 Link to comment Share on other sites More sharing options...
2toe Bigboots Posted April 3, 2012 Author Share Posted April 3, 2012 Awesome i knew i did something stupid 1) not reading more on getnotecardline lol 2) trying to write when tierd lol Once again Darkie your a life saver!!!! Link to comment Share on other sites More sharing options...
Recommended Posts
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