Get Primitive Data

31 July 2019

  • C10 - added the selection optional parameter.

19 May 2015

  • Release 8.12 - range is now an optional parameter and not required to locate the item.
getprimitivedata (Commands)
TypeCorrade progressive command
Commandgetprimitivedata
DescriptionCorrade can query data on primitives using the getprimitivedata command.
Permissionsinteract
Parametersgroup, password, item, data
Last ChangesRelease 8.12 - range is now an optional parameter and not required to locate the item.

Corrade can query data on primitives using the getprimitvedata command.

Command Required Parameters Required Corrade Permissions Example
getprimitivedata group, password, item, data interact
llInstantMessage(CORRADE,
    wasKeyValueEncode(
        [
            "command", "getprimitivedata",
            "group", wasURLEscape(GROUP),
            "password", wasURLEscape(PASSWORD),
            "item", "Vendor",
            // searches in a 5m range
            "range", "5",
            // returns the position and primitive text as CSV
            "data", wasListToCSV(
                [
                    "Position",
                    "Text"
                ]
            ),
            "callback", wasURLEscape(URL)
        ]
    )
);

The data parameter follows the libopenmetaverse Primitive structure and sub-structures.

Optional Parameter Possible Value Description
range A range in meters. The spherical distance from Corrade in which to locate the item.
selection attached, rezzed or all (default: all) Either attached, rezzed or all for selecting only primitives or objects attached to avatars, primitives or objects rezzed in-world or all primitives or objects respectively.

the return values are a CSV list of fields or properties to their corresponding values. For example, suppose you wanted to query the rotation and overhead text of a primitive. In that case you would issue:

llInstantMessage(CORRADE,
    wasKeyValueEncode(
        [
            "command", "getprimitivedata",
            "group", wasURLEscape(GROUP),
            "password", wasURLEscape(PASSWORD),
            "item", "Vendor",
            // searches in a 5m range
            "range", "5",
            // returns the rotation and primitive text
            "data", wasListToCSV(
                [
                    "Rotation",
                    "Text"
                ]
            ),
            "callback", wasURLEscape(URL)
        ]
    )
);

and Corrade would return the string:

group=MyGroup&success=True&data=Rotation,"<0, 0, 0, 1>",Text,"Good day!"

Now to extract the value of the text component "Good day!", we process the data in http_request:

http_request(key id, string method, string body) {
    // always confirm reception or the request will time-out
    llHttpResponse(id, 200, "Ok");
 
    // de-serialize the value of the "data" key to a list
    list data = wasCSVToList(
        wasURLUnescape(
            wasKeyValueGet(
                "data",
                body
            )
        )
    );
 
    // now "data" will look like:
    // data = [ "rotation", "<0, 0, 0, 1>", "text", "Good day!" ];
    // and since we want to grab the "text", we search the data
    // list for the string "text" and return the value
    string text = llList2String(
        data,
        llListFindList(
            data,
            ["Text"]
        )+1
    );
 
    // now we have the text and can do something with it
    llOwnerSay(text);
}

Notes