The osGetNotecard
function manifests arbitrary behavior when reading from the primitive's inventory. This was tested with a few notecards below the 255 byte limit (the limit does not seem to matter since osGetNotecard
will read much more than that anyway). Do not use this script, it will be useful once the OpenSim developers have fixed their own OSSL code.
////////////////////////////////////////////////////////// // (c) Wizardry and Steamworks - 2013, License GPLv3 // // Please see: http://www.gnu.org/licenses/gpl.html // // for legal details, rights of fair usage and // // the disclaimer and warranty conditions. // ////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////// // Copyright (C) 2013 Wizardry and Steamworks - License: GNU GPLv3 // /////////////////////////////////////////////////////////////////////////// string wasKeyValueGet(string var, string kvp) { list dVars = llParseString2List(kvp, ["&"], []); do { list data = llParseString2List(llList2String(dVars, 0), ["="], []); string k = llList2String(data, 0); if(k != var) jump continue; return llList2String(data, 1); @continue; dVars = llDeleteSubList(dVars, 0, 0); } while(llGetListLength(dVars)); return ""; } /////////////////////////////////////////////////////////////////////////// // Copyright (C) 2013 Wizardry and Steamworks - License: GNU GPLv3 // /////////////////////////////////////////////////////////////////////////// string wasKeyValueSet(string var, string val, string kvp) { list dVars = llParseString2List(kvp, ["&"], []); if(llGetListLength(dVars) == 0) return var + "=" + val; list result = []; do { list data = llParseString2List(llList2String(dVars, 0), ["="], []); string k = llList2String(data, 0); if(k == "") jump continue; if(k == var && val == "") jump continue; if(k == var) { result += k + "=" + val; val = ""; jump continue; } string v = llList2String(data, 1); if(v == "") jump continue; result += k + "=" + v; @continue; dVars = llDeleteSubList(dVars, 0, 0); } while(llGetListLength(dVars)); if(val != "") result += var + "=" + val; return llDumpList2String(result, "&"); } string question = ""; default { state_entry() { llListen(0, "", "", ""); } touch_start(integer num) { integer line = (integer)wasKeyValueGet("line", llGetObjectDesc()); if(line+1 > osGetNumberOfNotecardLines("Questions")-1) line = 0; question = osGetNotecardLine("Questions", line++); llSetObjectDesc(wasKeyValueSet("line", (string)line, llGetObjectDesc())); llSay(0, question); } listen(integer channel, string name, key id, string message) { // reformat answer to CSV message = name + "→" + question + "→" + message + "\n"; if(llGetInventoryType(name) != INVENTORY_NOTECARD) jump commit; // make sure that the question has not been already answered, // if it was already answered, delete the previous answer and // replace it with the new answer from local chat. string m = name + "→" + question + "→"; list data = llParseString2List(osGetNotecard(name), ["\n"], []); integer i = llGetListLength(data)-1; do { if(llSubStringIndex(llList2String(data, i), m) != -1) { data = llDeleteSubList(data, i , i); jump break; } } while(--i>-1); @break; message = llDumpList2String(data, "\n") + "\n" + message; llRemoveInventory(name); @commit; osMakeNotecard(name, message); } on_rez(integer num) { llResetScript(); } }