Get Self Data

getselfdata (Commands)
TypeCorrade progressive command
Commandgetselfdata
DescriptionThe getselfdata queries the AgentManager class for the current Corrade bot.
Permissionsgrooming
Parametersgroup, password, data
Last Changesnone

The getselfdata queries the AgentManager class for the current Corrade bot. In other words, it can be used to query things such as the bot's health, velocity, rotation, etc...

Command Required Parameters Required Corrade Permissions Example
getselfdata group, password, data grooming
llInstantMessage(CORRADE,
    wasKeyValueEncode(
        [
            // get the health and
            // velocity of the bot
            "command", "getselfdata",
            "group", wasURLEscape(GROUP),
            "data", wasListToCSV(
                [
                    "Health",
                    "Velocity"
                ]
            ),
            "password", wasURLEscape(PASSWORD),
            "callback", wasURLEscape(URL)
        ]
    )
);

Determine if Corrade is Sitting on An Object

One way to determine if Corrade is sitting down or not is to query the SittingOn property:

llInstantMessage(CORRADE,
    wasKeyValueEncode(
        [
            "command", "getselfdata",
            "group", wasURLEscape(GROUP),
            "data", "SittingOn",
            "password", wasURLEscape(PASSWORD),
            "callback", wasURLEscape(URL)
        ]
    )
);

This will send the result to the callback URL which will be a string such as:

group=My Group&command=data=SittingOn,35534&success=True

We now need to extract SittingOn from this string and, perhaps the easiest, to do that is to do the following:

http_request(key id, string method, string body) {
    // Send OK
    llHTTPResponse(id, 200, "Ok");
 
    if(wasKeyValueGet("success", body) == "False") {
        llOwnerSay("Failed to query Corrade.");
        return;
    }
 
    // Function calls in order:
    // 1.) Unescape the string sent by Corrade. (wasURLUnescape)
    // 2.) Get the "data" key. (wasKeyValueGet)
    // 3.) Convert the CSV to a list. (wasCSVToList)
    // the list will contain "SittingOn" at index 0
    // and the value of "SittingOn" at index 1
    // 4.) Get the second element in the list (index 1). (llList2Integer)
    // 5.) Compare the second element to 0 and assign to "sitting".
    integer sitting = llList2Integer(
        wasCSVToList(
            wasKeyValueGet(
                "data",
                wasURLUnescape(body)
            )
        ),
        1 // index 1
    ) != 0;
 
    if(sitting) {
        // Corrade is sitting
        llOwnerSay("Corrade is sitting!");
        return;
    }
    // Corrade is not sitting
    llOwnerSay("Corrade is not sitting!");
}

which will tell the owner if Corrade is sitting or not.


secondlife/scripted_agents/corrade/api/progressive/commands/getselfdata.txt ยท Last modified: 2017/02/22 18:27 (external edit)

Access website using Tor


For the copyright, license, warranty and privacy terms for the usage of this website please see the license and privacy pages.