Updates the key-value pair string kvp
with the parameters from a string data
and returns the result as a key-value pair.
data
string in description format, eg variable_1=value_1&variable_2=value_2
.kvp
, setting the new variables from data
and leaving the rest of the variables intact.Suppose that the object description is:
toggle=on&target=<0,0,1>&sound=off
and that we call the function as:
llSetObjectDesc(wasKeyValueUpdate("toggle=off&sound=on", llGetObjectDesc()));
then the object description will be updated to:
toggle=off&target=<0,0,1>&sound=on
Suppose that the object description is:
toggle=on&target=<0,0,1>&sound=off
and that we call the function as:
llSetObjectDesc(wasKeyValueUpdate("toggle=off&special=k", llGetObjectDesc()));
then the object description will be updated to:
toggle=off&target=<0,0,1>&sound=off
The extra key-value pair special=k
gets ignored.
/////////////////////////////////////////////////////////////////////////// // Copyright (C) 2014 Wizardry and Steamworks - License: CC BY 2.0 // /////////////////////////////////////////////////////////////////////////// string wasKeyValueUpdate(string in, string up) { list org = llParseString2List(in, ["&", "="], []); list dst = llParseString2List(up, ["&", "="], []); list out = []; do { if(llListFindList(org, [llList2String(dst, 0)]) == -1) { out += llList2String(org, 0) + "=" + llList2String(org, 1); jump continue; } out += llList2String(org, 0) + "=" + llList2String(dst, 1); @continue; dst = llDeleteSubList(dst, 0, 1); } while(llGetListLength(dst) != 0); return llDumpList2String(out, "&"); }