I searched, and maybe my wording is terrible and this was already suggested but throwing myself out there anyway.
Can we have features that let us access list entries in ways similar to some other modern scripting languages do?
Since some of the GLTF functions support multiple argument types (which afaik is a first for SL, that a function parameter can optionally have int or string), I'm thinking it could be possible to do something like this:
  • someList[0], returns list element index 0 (first element)
  • someList[3, 1], returns the first element AFTER 3 (so effectively the 5th element (index 4))
  • someList["an entry"], returns the first list element containing "an entry"
  • someList["an entry", 1], returns the element succeeding "an entry", if both exist
  • someList["an entry", -1], returns the element PREceding "an entry", if both exist
This would always return a string, and I'm led to understand most people use llList2String and typecast to their desired parameter type anyway, so this should be familiar behaviour.
Returns empty string, if the element does not exist.
Here are some examples:
list test = ["blob", "some", "value"];
llOwnerSay(test[1]); // Outputs "some"
llOwnerSay(test["some"]); // Outputs "some"
llOwnerSay(test[1, 1]); // outputs "value"
llOwnerSay(test["some", 1]); // outputs "value"
llOwnerSay(test["some", -1]); // outputs "blob", as the element BEFORE "some"
llOwnerSay(test["not present"]); // Outputs ""
llOwnerSay(test[1337]); // Outputs ""
I am not sure if there would be any performance benefits to reading lists that way, but I think it would be a great convenience option.
This kind of functionality would obsolete llList2String and make strided lists much easier to work with, if we don't have to dedicate script time to doing the math.
I'd also love to be able to edit lists in a similar fashion like: someList[3] = "New value"; but I'll take what I can get!