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/commands/getselfdata.txt · Last modified: 2022/11/24 07:45 by 127.0.0.1

Access website using Tor Access website using i2p Wizardry and Steamworks PGP Key


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