ScriptDiscoveryService

Description

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

The ScriptDiscoveryService API provides facilities to work with Interface scripts.

Properties

Name Type Summary
debugScriptUrl string

The path and name of a script to debug using the "API Debugger" developer tool (currentAPI.js). If set, the API Debugger dialog displays the objects and values exposed by the script using Script.registerValue and similar.

Default Value: ""

defaultScriptsPath string

The path where the default scripts are located in the Interface installation. Read-only.

scriptsModel ScriptsModel

Information on the scripts that are in the default scripts directory of the Interface installation. Read-only.

scriptsModelFilter ScriptsModelFilter

Sorted and filtered information on the scripts that are in the default scripts directory of the Interface installation. Read-only.

Methods

Name Return Value Summary
getLocal Array.<ScriptDiscoveryService.LocalScript>

Deprecated: This function is deprecated and will be removed.

getPublic Array.<ScriptDiscoveryService.PublicScript>

Gets a list of all script files that are in the default scripts directory of the Interface installation.

getRunning Array.<ScriptDiscoveryService.RunningScript>

Gets a list of all Interface scripts that are currently running.

loadOneScript None

Starts running an Interface script, if it isn't already running. The script is automatically loaded next time Interface starts.

This is a synonym for calling loadScript with just the script URL.

Supported Script Types: Interface Scripts • Avatar Scripts

See also, Script.load.

loadScript object

Starts running an Interface script, if it isn't already running.

Supported Script Types: Interface Scripts • Avatar Scripts

See also, Script.load.

onClearDebugWindow None

Deprecated: This function is deprecated and will be removed.

onErrorLoadingScript None

Deprecated: This function is deprecated and will be removed.

onErrorMessage None

Deprecated: This function is deprecated and will be removed.

onInfoMessage None

Deprecated: This function is deprecated and will be removed.

onPrintedMessage None

Deprecated: This function is deprecated and will be removed.

onScriptFinished None

Deprecated: This function is deprecated and will be removed.

onWarningMessage None

Deprecated: This function is deprecated and will be removed.

reloadAllScripts None

Restarts all Interface, avatar, and client entity scripts after clearing the scripts cache.

stopAllScripts None

Stops or restarts all Interface scripts. The scripts cache is not cleared. If restarting, avatar and client entity scripts are also restarted.

stopScript boolean

Stops or restarts an Interface script.

Signals

Name Summary
clearDebugWindow

Triggered when the Debug Window is cleared.

errorLoadingScript

Deprecated: This signal is deprecated and will be removed.

errorMessage

Triggered when any script generates an error or console.error is called.

infoMessage

Triggered when any script generates an information message or console.info is called.

printedMessage

Triggered when any script prints a message to the program log via print, Script.print, console.log, or console.debug.

scriptCountChanged

Triggered when the number of Interface scripts running changes.

scriptLoadError

Triggered when a script could not be loaded.

scriptsReloading

Triggered when Interface, avatar, and client entity scripts are restarting as a result of reloadAllScripts or stopAllScripts.

warningMessage

Triggered when any script generates a warning or console.warn is called.

Type Definitions

LocalScript
Type: object

Information on a local script.

Deprecated: This type is deprecated and will be removed.

Properties

Name Type Summary
name string

The script's file name.

path string

The script's path.

PublicScript
Type: object

Information on a public script, i.e., a script that's included in the Interface installation.

Properties

Name Type Attributes Summary
name string

The script's file name.

type string

"script" or "folder".

Deprecated: This property is deprecated and will be removed. It currently always has the value, "script".

children Array.<ScriptDiscoveryService.PublicScript> <optional>

Only present if type == "folder".

Deprecated: This property is deprecated and will be removed. It currently is never present.

url string <optional>

The full URL of the script — including the "file:///" scheme at the start.

Only present if type == "script".

RunningScript
Type: object

Information on a running script.

Properties

Name Type Summary
local boolean

true if the script is a local file (i.e., the scheme is "file"), false if it isn't (e.g., the scheme is "http").

name string

The script's file name.

path string

The script's path and file name — excluding the scheme if a local file.

url string

The full URL of the script — including the scheme if a local file.

Method Details

(static) getLocal( ) → {Array.<ScriptDiscoveryService.LocalScript>}
Returns: Local scripts.

Deprecated: This function is deprecated and will be removed.

(static) getPublic( ) → {Array.<ScriptDiscoveryService.PublicScript>}
Returns: All scripts in the "scripts" directory of the Interface installation.

Gets a list of all script files that are in the default scripts directory of the Interface installation.

(static) getRunning( ) → {Array.<ScriptDiscoveryService.RunningScript>}
Returns: All Interface scripts that are currently running.

Gets a list of all Interface scripts that are currently running.

Example

Report all running scripts.

var runningScripts = ScriptDiscoveryService.getRunning();
print("Running scripts:");
for (var i = 0; i < runningScripts.length; i++) {
    print(JSON.stringify(runningScripts[i]));
}
(static) loadOneScript( url )

Starts running an Interface script, if it isn't already running. The script is automatically loaded next time Interface starts.

This is a synonym for calling loadScript with just the script URL.

Supported Script Types: Interface Scripts • Avatar Scripts

See also, Script.load.

Parameters

Name Type Description
url string

The path and name of the script. If a local file, including the "file:///" scheme is optional.

(static) loadScript( urlopt, isUserLoadedopt, loadScriptFromEditoropt, activateMainWindowopt, reloadopt, quitWhenFinishedopt ) → {object}
Returns: An empty object, {}.

Starts running an Interface script, if it isn't already running.

Supported Script Types: Interface Scripts • Avatar Scripts

See also, Script.load.

Parameters

Name Type Attributes Default Value Description
url string <optional>
""

The path and name of the script. If a local file, including the "file:///" scheme is optional.

isUserLoaded boolean <optional>
true

true if the user specifically loaded it, false if not (e.g., a script loaded it). If false, the script is not automatically loaded next time Interface starts.

loadScriptFromEditor boolean <optional>
false

Not used.

activateMainWindow boolean <optional>
false

Not used.

reload boolean <optional>
false

true to redownload the script, false to use the copy from the cache if available.

quitWhenFinished boolean <optional>
false

true to close Interface when the script finishes, false to not close Interface.

(static) onClearDebugWindow( )

Deprecated: This function is deprecated and will be removed.

(static) onErrorLoadingScript( url )

Deprecated: This function is deprecated and will be removed.

Parameters

Name Type Description
url string

URL.

(static) onErrorMessage( message, scriptName )

Deprecated: This function is deprecated and will be removed.

Parameters

Name Type Description
message string

Message.

scriptName string

Script name.

(static) onInfoMessage( message, scriptName )

Deprecated: This function is deprecated and will be removed.

Parameters

Name Type Description
message string

Message.

scriptName string

Script name.

(static) onPrintedMessage( message, scriptName )

Deprecated: This function is deprecated and will be removed.

Parameters

Name Type Description
message string

Message.

scriptName string

Script name.

(static) onScriptFinished( scriptName, engine )

Deprecated: This function is deprecated and will be removed.

Parameters

Name Type Description
scriptName string

Script name.

engine object

Engine.

(static) onWarningMessage( message, scriptName )

Deprecated: This function is deprecated and will be removed.

Parameters

Name Type Description
message string

Message.

scriptName string

Script name.

(static) reloadAllScripts( )

Restarts all Interface, avatar, and client entity scripts after clearing the scripts cache.

(static) stopAllScripts( restartopt )

Stops or restarts all Interface scripts. The scripts cache is not cleared. If restarting, avatar and client entity scripts are also restarted.

Parameters

Name Type Attributes Default Value Description
restart boolean <optional>
false

true to restart the scripts, false to stop them.

(static) stopScript( url, restartopt ) → {boolean}
Returns: true if the script was successfully stopped or restarted, false if it wasn't (e.g., the script couldn't be found).

Stops or restarts an Interface script.

Parameters

Name Type Attributes Default Value Description
url string

The path and name of the script. If a local file, including the "file:///" scheme is optional.

restart boolean <optional>
false

true to redownload and restart the script, false to stop it.

Signal Details

clearDebugWindow( )
Returns: Signal

Triggered when the Debug Window is cleared.

errorLoadingScript( url )
Returns: Signal

Deprecated: This signal is deprecated and will be removed.

Parameters

Name Type Description
url string

URL.

errorMessage( message, scriptName )
Returns: Signal

Triggered when any script generates an error or console.error is called.

Parameters

Name Type Description
message string

The error message.

scriptName string

The name of the script that generated the error message.

infoMessage( message, scriptName )
Returns: Signal

Triggered when any script generates an information message or console.info is called.

Parameters

Name Type Description
message string

The information message.

scriptName string

The name of the script that generated the informaton message.

printedMessage( message, scriptName )
Returns: Signal

Triggered when any script prints a message to the program log via print, Script.print, console.log, or console.debug.

Parameters

Name Type Description
message string

The message.

scriptName string

The name of the script that generated the message.

scriptCountChanged( )
Returns: Signal

Triggered when the number of Interface scripts running changes.

Example

Report when the number of running scripts changes.

ScriptDiscoveryService.scriptCountChanged.connect(function () {
    print("Scripts count changed: " + ScriptDiscoveryService.getRunning().length);
});
scriptLoadError( url, error )
Returns: Signal

Triggered when a script could not be loaded.

Parameters

Name Type Description
url string

The path and name of the script that could not be loaded.

error string

"" always.

scriptsReloading( )
Returns: Signal

Triggered when Interface, avatar, and client entity scripts are restarting as a result of reloadAllScripts or stopAllScripts.

warningMessage( message, scriptName )
Returns: Signal

Triggered when any script generates a warning or console.warn is called.

Parameters

Name Type Description
message string

The warning message.

scriptName string

The name of the script that generated the warning message.