User:peter Stindberg/is uuid

From Second Life Wiki
Jump to navigation Jump to search

Summary

Function: integer is_uuid( key uuid );

Created by Peter Stindberg, this function will take a key as input and return TRUE or FALSE depending on wether the key is a valid Second Life agent UUID. There are two formal checks there for key-length and number of dashes in the string.
integer is_uuid(key uuid) {
    return (
           (llStringLength(uuid) == 36) 
        && (llGetSubString(uuid, 14, 14) == "4")
        && (llGetListLength(llParseString2List(uuid, ["-"], [])) == 5)
    );
}

Returns an integer TRUE or FALSE.
• key uuid UUID to be checked wether it is an agent or not (group, object, ...).

Caveats

The function checks for a signal that is widely believed to be only part of agent UUID's and not object UUID's. Extensive tests by Peter Stindberg as well as other users have shown no counter-example up to date. There is no guarantee that is true for all agent UUID's, nor that it won't change in the future.

Examples

Deep Notes

Signature

function integer is_uuid( key uuid );