Change Configuration File

2 April 2014

  • Release 7.93 - added the set and get options and removed the Base64 requirement.

14 December 2014

  • Release 7.28 - added.
configuration (Commands)
TypeCorrade progressive command
Commandconfiguration
DescriptionThe configuration command allows an authenticated group that has the system permission to read and write Corrade's configuration file.
Permissionssystem
Parametersgroup, password, action
Last ChangesRelease 7.93 - added the set and get options and removed the Base64 requirement.

The configuration command allows an authenticated group that has the system permission to read and write Corrade's configuration file. Note that when the configuration file is written to, Corrade reloads its configuration file automatically such that this command can be used to configure Corrade dynamically.

Command Required Parameters Required Corrade Permissions Example
configuration group, password, action system
llInstantMessage(CORRADE,
    wasKeyValueEncode(
        [
            // read and return Corrade's 
            // configuration file as part
            // of the "data" return key
            "command", "configuration",
            "group", wasURLEscape(GROUP),
            "password", wasURLEscape(PASSWORD),
            "action", "read",
            "callback", wasURLEscape(URL)
        ]
    )
);
Parameter Value Secondary Parameters Description
action read Read the entire configuration file and pass it to the data key.
write data Write all the data passed through the data key to the configuration file.
get path Get the inner XML of a node specified by the XPath path.
set path, data Write the inner XML in data of a node specified by the XPath path to the configuration file.

The get and set actions allow you to manipulate the XML nodes individually which eases the configuration of Corrade under size constraints (such as LSL). Both of them require a secondary parameter path that is an XPath to a node whose inner XML you wish to modify. set additionally takes an XML snippet and will replace the node specified by path with data.

Tutorials

The configuration command is very powerful and could be exactly the type of command you would need in order to create some shared-dynamic hosting of Corrade bots. The command gives you access to Corrade's configuration file, allowing you to get and set raw XML and set the value of any key in Corrade's configuration.

Furthermore, whenever you change the configuration using this command, Corrade saves the configuration to Corrade.ini, such that the modifications you make are permanent. You could even use this command to make Corrade re-log on a different account.

Selecting XML Nodes (Chunks of Data)

In some applications you may want to retrieve the currently configured groups as a chunk of XML and then process it. You could, for instance, select “the first group”:

llInstantMessage(CORRADE,
    wasKeyValueEncode(
        [
            "command", "configuration",
            "group", wasURLEscape(GROUP),
            "password", wasURLEscape(PASSWORD),
            "action", "get",
            "path", wasURLEscape(
                "/Configuration/
                    Groups/
                        Group[1]"
            ),
            "callback", wasURLEscape(URL)
        ]
    )
);

which will return the inner-XML of the first group in the configuration.

Otherwise, to retrieve all the groups as an XML chunk, you would do:

llInstantMessage(CORRADE,
    wasKeyValueEncode(
        [
            "command", "configuration",
            "group", wasURLEscape(GROUP),
            "password", wasURLEscape(PASSWORD),
            "action", "get",
            "path", wasURLEscape(
                "/Configuration/
                    Groups"
            ),
            "callback", wasURLEscape(URL)
        ]
    )
);

which will return all the inner-XML inside the Groups tag:

<Group>
    <Name>One Group</Name>
    ...
</Group>
<Group>
    <Name>Wizardry and Steamworks</Name>
    ...
</Group>
<Group>
    <Name>Chocolat</Name>
    ...
</Group>

this XML can then be processed, modified and then updated by using the set action and passing the XML to the data key.

Querying Group Information

Since Corrade uses XML XPath semantics for get and set actions, it is possible to determine specific configuration keys for a given group. For instance, suppose that we wanted to retrieve how many Workers are enabled for a configured group named Wizardry and Steamworks. In order to do that, we would issue the command:

llInstantMessage(CORRADE,
    wasKeyValueEncode(
        [
            "command", "configuration",
            "group", wasURLEscape(GROUP),
            "password", wasURLEscape(PASSWORD),
            "action", "get",
            "path", wasURLEscape(
                "/Configuration/
                    Groups/
                        Group[Name='Wizardry and Steamworks']/
                            Workers"
            ),
            "callback", wasURLEscape(URL)
        ]
    )
);

This command reads as: “select from root Configuration the Group sub-node and select the sub-sub-node Group where the Name tag is equal to Wizardry and Steamworks. The return to the callback will be a an integer that corresponds to the Workers configured for the group Wizardry and Steamworks.

Let's say that we wanted to increment the Workers now. We issue:

llInstantMessage(CORRADE,
    wasKeyValueEncode(
        [
            "command", "configuration",
            "group", wasURLEscape(GROUP),
            "password", wasURLEscape(PASSWORD),
            "action", "get",
            "path", wasURLEscape(
                "/Configuration/
                    Groups/
                        Group[Name='Wizardry and Steamworks']/
                            Workers"
            ),
            "data", 10,
            "callback", wasURLEscape(URL)
        ]
    )
);

which would perform the same steps to select the Workers sub-sub-node of the Wizardry and Steamworks group and then set its value to 10.

Enabling and Disabling the AI Component

For example, suppose that we want to query whether SIML is enabled in the configuration file. We would send the command:

llInstantMessage(CORRADE,
    wasKeyValueEncode(
        [
            // Check whether SIML is enabled.
            "command", "configuration",
            "group", wasURLEscape(GROUP),
            "password", wasURLEscape(PASSWORD),
            "action", "get",
            "path", wasURLEscape("/Configuration/EnableSIML"),
            "callback", wasURLEscape(URL)
        ]
    )
);

Corrade will then browse Configuration->EnableSIML and return its inner-most XML - in this case, either true or false. Supposing that it is false, it means that AIML is disabled. So, in order to enable AIML, we use the set parameter to action and issue:

llInstantMessage(CORRADE,
    wasKeyValueEncode(
        [
            // Enable SIML in Corrade's configuration.
            "command", "configuration",
            "group", wasURLEscape(GROUP),
            "password", wasURLEscape(PASSWORD),
            "action", "set",
            "path", wasURLEscape("/Configuration/EnableSIML"),
            "data", "true",
            "callback", wasURLEscape(URL)
        ]
    )
);

which will modify the configuration file and set Configuration->EnableSIML to true.

This feature is particularly useful due to the fact that Corrade dynamically reload its configuration file. In this example, by enabling the SIML feature, Corrade will start compiling the SIML brain and making the feature available without requiring a restart.

Making Corrade re-Log on a Different Account

To make Corrade re-log on a different account, you would have to:

  • make sure you have a restarter that will restart Corrade when it logs out of the grid.
  • use the configuration command to set FirstName, LastName and Password nodes to the data of the account to log onto. Corrade will save the configuration.
  • issue a logout command. Corrade will now log out.
  • when the restarter restarts Corrade, Corrade will read the configuration file and connect to the different account.

secondlife/scripted_agents/corrade/api/progressive/commands/configuration.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.