ScriptsModelFilter

Description

Supported Script Types: Interface Scripts • Client Entity Scripts • Avatar Scripts

Sorted and filtered information on the scripts that are in the default scripts directory of the Interface installation. This is provided as a property of ScriptDiscoveryService.

The information provided reflects the subdirectory structure. Properties, methods, and signals are per QT's QSortFilterProxyModel class, with the following details:

  • The rows are sorted per directory and file names.
  • A single column of data: columnCount(index) returns 1.
  • Data is provided for the following roles:
    RoleValueDescription
    Display0The directory or script file name.
    Path256The path and filename of the data item if it is a script, undefined if it is a directory.
  • Use null for the root directory's index.

Example

List all scripts that include "edit" in their name.

var DISPLAY_ROLE = 0;
var PATH_ROLE = 256;

function printDirectory(parentIndex, directoryLevel, indent) {
    var numRows = ScriptDiscoveryService.scriptsModelFilter.rowCount(parentIndex);
    for (var i = 0; i < numRows; i++) {
        var rowIndex = ScriptDiscoveryService.scriptsModelFilter.index(i, 0, parentIndex);

        var name = ScriptDiscoveryService.scriptsModelFilter.data(rowIndex, DISPLAY_ROLE);
        var hasChildren = ScriptDiscoveryService.scriptsModelFilter.hasChildren(rowIndex);
        var path = hasChildren ? "" : ScriptDiscoveryService.scriptsModelFilter.data(rowIndex, PATH_ROLE);

        print(indent + "- " + name + (hasChildren ? "" : " - " + path));

        if (hasChildren) {
            printDirectory(rowIndex, directoryLevel + 1, indent + "    ");
        }
    }
}

ScriptDiscoveryService.scriptsModelFilter.filterRegExp = new RegExp("^.*edit.*$", "i");  // Set the filter.
print("Edit scripts:");
printDirectory(null, 0, "");  // null index for the root directory.