High Fidelity API Reference
Tools Used: JavaScript, JSDoc, GitHub Pages, Markdown, HTML, CSS
High Fidelity is available as an open-source platform, and all content is forked and hosted according to the distribution requirements set out in the Apache License 2.0.
This is a sample of High Fidelity's API documentation, forked and imported into this website. The content matches the original, but the formatting and theme have been adjusted to compile with Docusaurus.
Script
The Script API provides facilities for working with scripts.
Supported Script Types: Interface Scripts • Client Entity Scripts • Avatar Scripts • Server Entity Scripts • Assignment Client Scripts
Properties
| Name | Type | Summary |
|---|---|---|
| context | string | The context that the script is running in:
Read-only. |
Methods
| Name | Return Value | Summary |
|---|---|---|
None | Adds a function to the list of functions called when an entity event occurs on a particular entity. | |
None | Calls a method in an entity script. | |
None | Stops an interval timer set by setInterval. | |
None | Stops a timeout timer set by setTimeout. | |
string | Gets the context that the script is running in: Interface/avatar, client entity, server entity, or assignment client. | |
boolean | Checks whether the script is running as an assignment client script. | |
boolean | Checks whether the script is running as an Interface or avatar script. | |
boolean | Checks whether the application was compiled as a debug build. | |
boolean | Checks whether the script is running as a client entity script. | |
boolean | Checks whether an entity has an entity script running. | |
boolean | Checks whether the script is running as a server entity script. | |
None | Prints a message to the program log and emits Script.printedMessage. Alternatively, you can use print or one of the console API methods. | |
None | Removes a function from the list of functions called when an entity event occurs on a particular entity. | |
object | array | Provides access to methods or objects provided in an external JavaScript or JSON file. | |
object | Calls a function repeatedly, at a set interval. | |
object | Calls a function once, after a delay. | |
None | Stops and unloads the current script. Warning: If an assignment client script, the script gets restarted after stopping. |
Signals
| Name | Summary |
|---|---|
Triggered when the script has stopped. | |
Triggered when the script starts for the user. See also, Entities.preload. Supported Script Types: Client Entity Scripts • Server Entity Scripts | |
Triggered when the script generates an error, console.error or console.exception is called, or console.assert is called and fails. | |
Triggered when the script generates an information message or console.info is called. | |
Triggered when the script prints a message to the program log via print, Script.print, console.log, console.debug, console.group, console.groupEnd, console.time, or console.timeEnd. | |
Triggered when the running state of the script changes, e.g., from running to stopping. | |
Triggered when the script is stopping. | |
Triggered when a script generates an unhandled exception. | |
Triggered frequently at a system-determined interval. | |
Triggered when the script generates a warning or console.warn is called. |
Type Definitions
EntityEventEntityEvent Type: string | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
The name of an entity event. When the entity event occurs, any function that hasbeen registered for that event via Script.addEventHandler is called with parameters per the entity event. Properties
|
Method Details
addEventHandler(static) addEventHandler( entityID, eventName, handler ) | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
Adds a function to the list of functions called when an entity event occurs on a particular entity. Parameters
Example: Report when a mouse press occurs on a particular entity |
callEntityScriptMethod(static) callEntityScriptMethod( entityID, methodName, parametersopt, remoteCallerIDopt ) | |||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Calls a method in an entity script. Parameters
|
clearInterval(static) clearInterval( timer ) | ||||||
|---|---|---|---|---|---|---|
Stops an interval timer set by setInterval. Parameters
Example: Stop an interval timer |
clearTimeout(static) clearTimeout( timer ) | ||||||
|---|---|---|---|---|---|---|
Stops a timeout timer set by setTimeout. Parameters
Example: Stop a timeout timer |
getContext(static) getContext( ) → { string } Returns: The context that the script is running in:
|
|---|
Gets the context that the script is running in: Interface/avatar, client entity, server entity, or assignment client. |
isAgentScript(static) isAgentScript( ) → { boolean } Returns: |
|---|
Checks whether the script is running as an assignment client script. |
isClientScript(static) isClientScript( ) → { boolean } Returns: |
|---|
Checks whether the script is running as an Interface or avatar script. |
isDebugMode(static) isDebugMode( ) → { boolean } Returns: |
|---|
Checks whether the application was compiled as a debug build. |
isEntityClientScript(static) isEntityClientScript( ) → { boolean } Returns: |
|---|
Checks whether the script is running as a client entity script. |
isEntityScriptRunning(static) isEntityScriptRunning( entityID ) → { boolean } Returns: | ||||||
|---|---|---|---|---|---|---|
Checks whether an entity has an entity script running. Parameters
|
isEntityServerScript(static) isEntityServerScript( ) → { boolean } Returns: |
|---|
Checks whether the script is running as a server entity script. |
print(static) print( message ) | ||||||
|---|---|---|---|---|---|---|
Prints a message to the program log and emits Script.printedMessage. Alternatively, you can use print or one of the console API methods. Parameters
|
removeEventHandler(static) removeEventHandler( entityID, eventName, handler ) | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
Removes a function from the list of functions called when an entity event occurs on a particular entity. Parameters
|
require(static) require( module ) → { object | array } Returns: The value assigned to | ||||||
|---|---|---|---|---|---|---|
Provides access to methods or objects provided in an external JavaScript or JSON file. Parameters
|
setInterval(static) setInterval( function, interval ) → { object } Returns: A handle to the interval timer. This can be used in Script.clearInterval. | |||||||||
|---|---|---|---|---|---|---|---|---|---|
Calls a function repeatedly, at a set interval. Parameters
Example: Print a message every second |
setTimeout(static) setTimeout( function, timeout ) → { object } Returns: A handle to the timeout timer. This can be used in Script.clearTimeout. | |||||||||
|---|---|---|---|---|---|---|---|---|---|
Calls a function once, after a delay. Parameters
Example: Print a message once, after a second |
stop(static) stop( marshalopt ) | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|
Stops and unloads the current script. Warning: If an assignment client script, the script gets restarted after stopping. Parameters
Example: Stop a script after 5s |
Signal Details
doneRunningdoneRunning( ) Returns: Signal |
|---|
Triggered when the script has stopped. |
entityScriptPreloadFinishedentityScriptPreloadFinished( entityID ) Returns: Signal | ||||||
|---|---|---|---|---|---|---|
Triggered when the script starts for the user. See also, Entities.preload. Supported Script Types: Client Entity Scripts • Server Entity Scripts Parameters
Example: Get the ID of the entity that a client entity script is running in |
errorMessageerrorMessage( message, scriptName ) Returns: Signal | |||||||||
|---|---|---|---|---|---|---|---|---|---|
Triggered when the script generates an error, console.error or console.exception is called, or console.assert is called and fails. Parameters
|
infoMessaheinfoMessage( message, scriptName ) Returns: Signal | |||||||||
|---|---|---|---|---|---|---|---|---|---|
Triggered when the script generates an information message or console.info is called. Parameters
|
printedMessageprintedMessage( message, scriptName ) Returns: Signal | |||||||||
|---|---|---|---|---|---|---|---|---|---|
Triggered when the script prints a message to the program log via print, Script.print, console.log, console.debug, console.group, console.groupEnd, console.time, or console.timeEnd. Parameters
|
runningStateChangedrunningStateChanged( ) Returns: Signal |
|---|
Triggered when the running state of the script changes, e.g., from running to stopping. |
scriptEndingscriptEnding( ) Returns: Signal |
|---|
Triggered when the script is stopping. Example: Report when a script is stopping |
unhandledExceptionunhandledException( exception ) Returns: Signal | ||||||
|---|---|---|---|---|---|---|
Triggered when a script generates an unhandled exception. Parameters
Example: Report the details of an unhandled exception |
updateupdate( deltaTime ) Returns: Signal | ||||||
|---|---|---|---|---|---|---|
Triggered frequently at a system-determined interval. Parameters
Example: Report script update intervals |
warningMessagewarningMessage( message, scriptName ) Returns: Signal | |||||||||
|---|---|---|---|---|---|---|---|---|---|
Triggered when the script generates a warning or console.warn is called. Parameters
|