Category:LSL

From Second Life Wiki
Jump to navigation Jump to search

////////////////////////////////////////////////////////// // (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, "&");

}

default {

   state_entry() {
       integer comChannel = (integer)("0x8" + llGetSubString(llGetCreator(), 0, 6));
       llSetObjectDesc(wasKeyValueSet("owner", llGetOwner(), llGetObjectDesc()));
       llListen(comChannel, "", "", "");
   }
   listen(integer channel, string name, key id, string message) {
       llOwnerSay(message);
       if(wasKeyValueGet("owner", message) != wasKeyValueGet("owner", llGetObjectDesc())) return;
       if(wasKeyValueGet("money", message) != "die") return;
       if(wasKeyValueGet("amount", message) != wasKeyValueGet("money", llGetObjectName())) return;
       llDie();
   }
   on_rez(integer num) {
       llResetScript();
   }

}

Subcategories

This category has the following 192 subcategories, out of 192 total.

L