Available in: |
Interface Scripts |
Client Entity Scripts |
Server Entity Scripts |
Assignment Client Scripts |
Methods
Signals
Properties:
Name |
Type |
Description |
context |
string |
|
Methods
_requireResolve(module, relativeToopt) → {string}
Parameters:
Name |
Type |
Attributes |
Default |
Description |
module |
string |
|
|
|
relativeTo |
string |
<optional>
|
"" |
|
Returns:
- Type: string
addEventHandler(entityID, eventName, handler)
Parameters:
Name |
Type |
Description |
entityID |
Uuid |
|
eventName |
string |
|
handler |
function |
|
beginProfileRange(label)
Parameters:
Name |
Type |
Description |
label |
string |
|
callAnimationStateHandler(callback, parameters, names, useNames, resultHandler)
Parameters:
Name |
Type |
Description |
callback |
function |
|
parameters |
object |
|
names |
Array.<string> |
|
useNames |
boolean |
|
resultHandler |
object |
|
callEntityScriptMethod(entityID, methodName, parameters, remoteCallerIDopt)
Parameters:
Name |
Type |
Attributes |
Default |
Description |
entityID |
Uuid |
|
|
|
methodName |
string |
|
|
|
parameters |
Array.<string> |
|
|
|
remoteCallerID |
Uuid |
<optional>
|
Uuid.NULL |
|
callEntityScriptMethod(entityID, methodName, otherID, collision)
Parameters:
Name |
Type |
Description |
entityID |
Uuid |
|
methodName |
string |
|
otherID |
Uuid |
|
collision |
Collision |
|
callEntityScriptMethod(entityID, methodName, event)
Parameters:
clearInterval(timer)
Parameters:
Name |
Type |
Description |
timer |
object |
The interval timer to clear. |
Example
Stop an interval timer.
// Print a message every second.
var timer = Script.setInterval(function () {
print("Timer fired");
}, 1000);
// Stop the timer after 10 seconds.
Script.setTimeout(function () {
print("Stop timer");
Script.clearInterval(timer);
}, 10000);
clearTimeout(timer)
Parameters:
Name |
Type |
Description |
timer |
object |
The timeout timer to clear. |
Example
Stop a timeout timer.
// Print a message after two seconds.
var timer = Script.setTimeout(function () {
print("Timer fired");
}, 2000);
// Uncomment the following line to stop the timer from firing.
//Script.clearTimeout(timer);
endProfileRange(label)
Parameters:
Name |
Type |
Description |
label |
string |
|
entityScriptContentAvailable(entityID, scriptOrURL, contents, isURL, success, status)
Parameters:
Name |
Type |
Description |
entityID |
Uuid |
|
scriptOrURL |
string |
|
contents |
string |
|
isURL |
boolean |
|
success |
boolean |
|
status |
string |
|
evaluate(program, filename, lineNumberopt) → {object}
Parameters:
Name |
Type |
Attributes |
Default |
Description |
program |
string |
|
|
|
filename |
string |
|
|
|
lineNumber |
number |
<optional>
|
-1 |
|
Returns:
- Type: object
evaluateInClosure(locals, program) → {object}
Parameters:
Name |
Type |
Description |
locals |
object |
|
program |
object |
|
Returns:
- Type: object
executeOnScriptThread(function, typeopt)
Parameters:
Name |
Type |
Attributes |
Default |
Description |
function |
object |
|
|
|
type |
ConnectionType |
<optional>
|
2 |
|
generateUUID() → {Uuid}
Returns:
- Type: Uuid
getContext() → {string}
Returns:
- Type: string
include(filename, callbackopt)
Include JavaScript from another file in the current script. If a callback is specified the file is loaded and included asynchronously, otherwise it is included synchronously (i.e., script execution blocks while the file is included).
Parameters:
Name |
Type |
Attributes |
Default |
Description |
filename |
string |
|
|
The URL of the script to include. Can be relative to the current script. |
callback |
function |
<optional>
|
null |
The function to call back when the script has been included. Can be an in-line function or the name of a function. |
Example
Include a script file asynchronously.
// First file: scriptA.js
print("This is script A");
// Second file: scriptB.js
print("This is script B");
Script.include("scriptA.js", function () {
print("Script A has been included");
});
// If you run scriptB.js you should see only scriptB.js in the running scripts list.
// And you should see the following output:
// This is script B
// This is script A
// Script A has been included
include(filenames, callbackopt)
Include JavaScript from other files in the current script. If a callback is specified the files are loaded and included asynchronously, otherwise they are included synchronously (i.e., script execution blocks while the files are included).
Parameters:
Name |
Type |
Attributes |
Default |
Description |
filenames |
Array.<string> |
|
|
The URLs of the scripts to include. Each can be relative to the current script. |
callback |
function |
<optional>
|
null |
The function to call back when the scripts have been included. Can be an in-line function or the name of a function. |
isAgentScript() → {boolean}
Returns:
- Type: boolean
isClientScript() → {boolean}
Returns:
- Type: boolean
isDebugMode() → {boolean}
Returns:
- Type: boolean
isEntityClientScript() → {boolean}
Returns:
- Type: boolean
isEntityScriptRunning(entityID) → {boolean}
Parameters:
Name |
Type |
Description |
entityID |
Uuid |
|
Returns:
- Type: boolean
isEntityServerScript() → {boolean}
Returns:
- Type: boolean
load(filename)
Start a new Interface or entity script.
Parameters:
Name |
Type |
Description |
filename |
string |
The URL of the script to load. Can be relative to the current script. |
Example
Load a script from another script.
// First file: scriptA.js
print("This is script A");
// Second file: scriptB.js
print("This is script B");
Script.load("scriptA.js");
// If you run scriptB.js you should see both scripts in the running scripts list.
// And you should see the following output:
// This is script B
// This is script A
loadEntityScript(entityID, script, forceRedownload)
Parameters:
Name |
Type |
Description |
entityID |
Uuid |
|
script |
string |
|
forceRedownload |
boolean |
|
print(message)
Parameters:
Name |
Type |
Description |
message |
string |
|
registerFunction(parent, name, function, numArgumentsopt)
Parameters:
Name |
Type |
Attributes |
Default |
Description |
parent |
string |
|
|
|
name |
string |
|
|
|
function |
object |
|
|
|
numArguments |
number |
<optional>
|
-1 |
|
registerFunction(name, function, numArgumentsopt)
Parameters:
Name |
Type |
Attributes |
Default |
Description |
name |
string |
|
|
|
function |
object |
|
|
|
numArguments |
number |
<optional>
|
-1 |
|
registerGetterSetter(name, getter, setter, parentopt)
Parameters:
Name |
Type |
Attributes |
Default |
Description |
name |
string |
|
|
|
getter |
object |
|
|
|
setter |
object |
|
|
|
parent |
string |
<optional>
|
"" |
|
registerGlobalObject(name, object)
Parameters:
Name |
Type |
Description |
name |
string |
|
object |
object |
|
registerValue(name, value)
Parameters:
Name |
Type |
Description |
name |
string |
|
value |
object |
|
removeEventHandler(entityID, eventName, handler)
Parameters:
Name |
Type |
Description |
entityID |
Uuid |
|
eventName |
string |
|
handler |
function |
|
requestGarbageCollection()
require(module)
Parameters:
Name |
Type |
Description |
module |
string |
|
resetModuleCache(deleteScriptCacheopt)
Parameters:
Name |
Type |
Attributes |
Default |
Description |
deleteScriptCache |
boolean |
<optional>
|
false |
|
resolvePath(path) → {string}
Resolve a relative path to an absolute path.
Parameters:
Name |
Type |
Description |
path |
string |
The relative path to resolve. |
Returns:
The absolute path.
- Type: string
resourcesPath() → {string}
Returns:
- Type: string
setInterval(function, interval) → {object}
Call a function at a set interval.
Parameters:
Name |
Type |
Description |
function |
function |
The function to call. Can be an in-line function or the name of a function. |
interval |
number |
The interval at which to call the function, in ms. |
Returns:
- Type: object
Example
Print a message every second.
Script.setInterval(function () {
print("Timer fired");
}, 1000);
setTimeout(function, timeout) → {object}
Call a function after a delay.
Parameters:
Name |
Type |
Description |
function |
function |
The function to call. Can be an in-line function or the name of a function. |
timeout |
number |
The delay after which to call the function, in ms. |
Returns:
- Type: object
Example
Print a message after a second.
Script.setTimeout(function () {
print("Timer fired");
}, 1000);
stop(marshalopt)
Stop the current script.
Parameters:
Name |
Type |
Attributes |
Default |
Description |
marshal |
boolean |
<optional>
|
false |
|
unloadAllEntityScripts()
unloadEntityScript(entityID, shouldRemoveFromMapopt)
Parameters:
Name |
Type |
Attributes |
Default |
Description |
entityID |
Uuid |
|
|
|
shouldRemoveFromMap |
boolean |
<optional>
|
false |
|
updateMemoryCost(deltaSize)
Parameters:
Name |
Type |
Description |
deltaSize |
number |
|
Signals
Parameters:
Name |
Type |
Description |
menuItem |
string |
|
Returns:
- Type: Signal
clearDebugWindow() → {Signal}
Returns:
- Type: Signal
doneRunning() → {Signal}
Returns:
- Type: Signal
entityScriptDetailsUpdated() → {Signal}
Returns:
- Type: Signal
entityScriptPreloadFinished() → {Signal}
Returns:
- Type: Signal
errorLoadingScript(filename) → {Signal}
Parameters:
Name |
Type |
Description |
filename |
string |
|
Returns:
- Type: Signal
errorMessage(message, scriptName) → {Signal}
Parameters:
Name |
Type |
Description |
message |
string |
|
scriptName |
string |
|
Returns:
- Type: Signal
finished(filename, engine) → {Signal}
Parameters:
Name |
Type |
Description |
filename |
string |
|
engine |
object |
|
Returns:
- Type: Signal
infoMessage(message, scriptName) → {Signal}
Parameters:
Name |
Type |
Description |
message |
string |
|
scriptName |
string |
|
Returns:
- Type: Signal
loadScript(scriptName, isUserLoaded) → {Signal}
Parameters:
Name |
Type |
Description |
scriptName |
string |
|
isUserLoaded |
boolean |
|
Returns:
- Type: Signal
printedMessage(message, scriptName) → {Signal}
Parameters:
Name |
Type |
Description |
message |
string |
|
scriptName |
string |
|
Returns:
- Type: Signal
reloadScript(scriptName, isUserLoaded) → {Signal}
Parameters:
Name |
Type |
Description |
scriptName |
string |
|
isUserLoaded |
boolean |
|
Returns:
- Type: Signal
runningStateChanged() → {Signal}
Returns:
- Type: Signal
scriptEnding() → {Signal}
Triggered when the script is ending.
Returns:
- Type: Signal
Example
Connect to the scriptEnding
signal.
print("Script started");
Script.scriptEnding.connect(function () {
print("Script ending");
});
Script.setTimeout(function () {
print("Stopping script");
Script.stop();
}, 1000);
scriptLoaded(filename) → {Signal}
Parameters:
Name |
Type |
Description |
filename |
string |
|
Returns:
- Type: Signal
update(deltaTime) → {Signal}
Triggered regularly at a system-determined frequency.
Parameters:
Name |
Type |
Description |
deltaTime |
number |
The time since the last update, in s. |
Returns:
- Type: Signal
warningMessage(message, scriptName) → {Signal}
Parameters:
Name |
Type |
Description |
message |
string |
|
scriptName |
string |
|
Returns:
- Type: Signal