Skip to content

Instantly share code, notes, and snippets.

@sl-service-account
Last active August 4, 2023 14:57
Show Gist options
  • Save sl-service-account/3a7f2cced16826880add358e0394cbca to your computer and use it in GitHub Desktop.
Save sl-service-account/3a7f2cced16826880add358e0394cbca to your computer and use it in GitHub Desktop.
Count, delete multiple LSD values by pattern
default {
state_entry() {
// Add some LSD values starting with "foo" and some that don't
llLinksetDataWrite("foobar", "a");
llLinksetDataWrite("foobaz", "a");
llLinksetDataWrite("foobaa", "a");
llLinksetDataWrite("woofie", "100");
llLinksetDataWrite("fungus", "500");
integer fooCount = llLinksetDataCountFound("^foo");
integer count = llLinksetDataCountKeys();
llOwnerSay("Added " + (string)count + " keys, " + (string)fooCount + " start with 'foo'");
}
touch_start(integer count) {
if (llDetectedKey(0) != llGetOwner()) { return; }
// Delete keys starting with "foo"...
list res = llLinksetDataDeleteFound("^foo", "");
integer deleteCount = llList2Integer(res, 0);
llOwnerSay("Deleted " + (string)deleteCount + " value(s) starting with foo");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment