“LlGetNotecardLine”的版本间的差异
第28行: | 第28行: | ||
•生成的对象不会产生新的使用限制,如果资产被放在prims库存中,可能会出现这种情况。 | •生成的对象不会产生新的使用限制,如果资产被放在prims库存中,可能会出现这种情况。 | ||
− | + | •如果name是一个新的空记事本卡(从未保存过),那么DEBUG频道上将出现错误“找不到notecard~name~”(~name~是name的值)。这是因为在第一次保存记事本卡之前,它并不是仅作为库存占位符作为资产存在的。 | |
•如果notecard是full perms,您可以使用llGetInventoryKey来检查它,在这种情况下,它将返回NULL_KEY。但是,如果notecard不是完全烫发,则无法避免错误消息。 | •如果notecard是full perms,您可以使用llGetInventoryKey来检查它,在这种情况下,它将返回NULL_KEY。但是,如果notecard不是完全烫发,则无法避免错误消息。 | ||
第84行: | 第84行: | ||
} | } | ||
} | } | ||
+ | ''' Useful Snippets ''' | ||
+ | <pre> | ||
− | |||
///// | ///// | ||
// Generic Multi Notecard reader by Brangus Weir | // Generic Multi Notecard reader by Brangus Weir | ||
第189行: | 第190行: | ||
} | } | ||
} | } | ||
+ | <pre> | ||
− | + | <pre> | |
− | |||
///// | ///// | ||
// Generic Multi Notecard reader by Randur Source | // Generic Multi Notecard reader by Randur Source |
2020年7月6日 (一) 08:36的最新版本
首页 | 函数 | 事件 | 类型 | 操作符 | 常数 | Flow Control | Script Library | Categorized Library | Tutorials |
函数名 |
---|
Function: key llGetNotecardLine( string name, integer line ); |
参数:
•字符串名称(string name)–此脚本所在的prim目录中的记事本或记事本卡的UUID •整数行( integer line )–记事本卡中的行号(索引从零开始)。 行不支持负索引。 如果行超过了notecard的结尾,则数据服务器将返回EOF。 |
返回值:从数据服务器请求notecard名称的行。
返回数据服务器事件响应的句柄(键)。 |
注意事项 |
---|
•此函数使脚本休眠0.1秒。
•如果行超出边界,脚本将继续执行而不显示错误消息。 •如果prim的清单中缺少name,并且它不是UUID或不是notecard,那么DEBUG峎CHANNEL上会发出一个错误。 •如果name是一个UUID,则对象没有新的资产权限后果。 •生成的对象不会产生新的使用限制,如果资产被放在prims库存中,可能会出现这种情况。 •如果name是一个新的空记事本卡(从未保存过),那么DEBUG频道上将出现错误“找不到notecard~name~”(~name~是name的值)。这是因为在第一次保存记事本卡之前,它并不是仅作为库存占位符作为资产存在的。 •如果notecard是full perms,您可以使用llGetInventoryKey来检查它,在这种情况下,它将返回NULL_KEY。但是,如果notecard不是完全烫发,则无法避免错误消息。 •如果notecard包含嵌入的库存项(如纹理和地标),则无论请求的行是什么,都将返回EOF。 •如果请求的行超过255个字节,数据服务器将返回该行的前255个字节。 Notes 记事本读卡可以是no modify,也可以是no modify/no copy。 |
示例 |
---|
示例1
key notecardQueryId; string notecardName = "name of notecard as in object's contents"; // script-wise, the first notecard line is line 0, the second line is line 1, etc. integer notecardLine; say(string inputString) { llOwnerSay(inputString); } default { state_entry() { // Check the notecard exists, and has been saved if (llGetInventoryKey(notecardName) == NULL_KEY) { llOwnerSay( "Notecard '" + notecardName + "' missing or unwritten"); return; } // say("reading notecard named '" + notecardName + "'."); notecardQueryId = llGetNotecardLine(notecardName, notecardLine); } dataserver(key query_id, string data) { if (query_id == notecardQueryId) { if (data == EOF) say("Done reading notecard, read " + (string) notecardLine + " notecard lines."); else { // bump line number for reporting purposes and in preparation for reading next line ++notecardLine; say( "Line: " + (string) notecardLine + " " + data); notecardQueryId = llGetNotecardLine(notecardName, notecardLine); } } } } ''' Useful Snippets ''' <pre> ///// // Generic Multi Notecard reader by Brangus Weir // Given freely and published on wiki.secondlife.com // // This script will read three note cards and store the results into three lists. // It can be modified and extended to as many (or few) cards as you'd like to read. // list gOneCard; // All the lines from from the first card list gTwoCard; // All the lines from from the second card list gThreeCard; // All the lines from from the third card string gsCardOneName = "One"; //Set these to the name of the invetory item. string gsCardTwoName = "Two"; string gsCardThreeName = "Three"; //Temporary variables for processing string g_sNoteCardName; // Name of the card to be read. list g_lTempLines; // The resulting data pushed into a list integer g_iLine; // The line count for the card reader key g_kQuery; // The key of the card being read initialize(string _action) { // Due to the execution order when using dataserver, this function sets the first card to // be read, and the excetuion finishes when called again with the _action set to "finish". if (_action == "") { loadNoteCard(gsCardOneName); } else if (_action == "finish") { // All cards have been read into the lists... now you can do any kind of string // manipulations to get the data you need to set your script. // But here we will prove that the cards have been read with a loop g_lTempLines = []; // lets not forget to delete this global, or it will be dead weight. integer len = llGetListLength(gOneCard); //Always evaluate this once, don't do it //INSIDE the for loop like noob programers will. //Reduce lag, THINK ABOUT MACHINE CYCLES! integer i = 0; for (; i< len; ++i) llSay(0, llList2String(gOneCard,i)); len = llGetListLength(gTwoCard); for (i = 0; i< len; ++i) llSay(0, llList2String(gTwoCard,i)); len = llGetListLength(gThreeCard); for (i = 0; i< len; ++i) llSay(0, llList2String(gThreeCard,i)); } } loadNoteCard( string _notecard ) { g_lTempLines = []; //clear the temp lines g_sNoteCardName = _notecard; g_iLine = 0; g_kQuery = llGetNotecardLine(g_sNoteCardName, g_iLine); } notecardFinished(string _notecard){ // Called at the end of each notecard as it is read. The temp results are stored // and the next card is commanded to be read. if (_notecard == gsCardOneName) { gOneCard = g_lTempLines; loadNoteCard(gsCardTwoName); } else if (_notecard == gsCardTwoName) { gTwoCard = g_lTempLines; loadNoteCard(gsCardThreeName); } else if (_notecard == gsCardThreeName) { gThreeCard = g_lTempLines; initialize("finish"); // Finally pass execution to finish the initialization. } } default { state_entry() { } touch_start(integer _num_det){ initialize(""); } dataserver(key _query_id, string _data) { if (_query_id == g_kQuery) { // this is a line of our notecard if (_data != EOF) { g_lTempLines += _data; //request a next line ++g_iLine; // increment line count g_kQuery = llGetNotecardLine(g_sNoteCardName, g_iLine); } else { //The notecard has been read //notify end of read notecardFinished(g_sNoteCardName); } } } } <pre> <pre> ///// // Generic Multi Notecard reader by Randur Source // Given freely and published on wiki.secondlife.com // // This script will read all note cards in sequence and dump the results into chat as an example. // It can be modified and extended to do other things to the data. // integer inventorycnt; integer notecardlinecnt; integer notecardlinenumber; string notecardname; key linenumberid; key lineid; getnextnotecardlinenumber() { // first get the number of lines from the notecard inventorycnt++; if (inventorycnt < llGetInventoryNumber(INVENTORY_NOTECARD)) { notecardname = llGetInventoryName(INVENTORY_NOTECARD,inventorycnt); linenumberid = llGetNumberOfNotecardLines(notecardname); } else llOwnerSay("Done."); } getnextnotecardline() { // get the next line from the notecard or skip to the next notecard notecardlinecnt++; if (notecardlinecnt < notecardlinenumber) lineid = llGetNotecardLine(notecardname,notecardlinecnt); else getnextnotecardlinenumber(); } default { touch_start(integer total_number) { if (llDetectedKey(0) != llGetOwner()) return; // allow owner only inventorycnt = -1; getnextnotecardlinenumber(); } dataserver(key queryid,string data) { if (queryid == linenumberid) // this was a line number lookup { linenumberid = NULL_KEY; notecardlinenumber = (integer)data; if (notecardlinenumber == 0) getnextnotecardlinenumber(); else { notecardlinecnt = -1; getnextnotecardline(); } } else if (queryid == lineid) // this was a data line lookup { lineid = NULL_KEY; // Example of what to do with the data: // Test for valid avatar names, possibly multiple names on each line, separated by , // and say them in chat to the owner list names = llParseString2List(data,[","],[]); // split lines on , integer len = llGetListLength(names); // I wouldn't dare to put this inside the for loop integer cnt; for (cnt = 0; cnt < len; cnt++) { string name = llDumpList2String(llParseString2List(llList2String(names,cnt),[" "],[])," "); // remove extra spaces if (llGetListLength(llParseString2List(name,[" "],[])) == 2) // check for first + lastname llOwnerSay(notecardname + ": " + name); } getnextnotecardline(); } } } |
相关函数 |
---|
无 |
相关事件 |
---|
无 |