Other great resources: Official JS API docs, Scripting Forum

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Next »

Overview

Enables additional javascript files to be included in your script.

Availability

Warzone 3.1 Beta 1 and above.

Syntax

include(filename);

Parameters

ParameterTypeMandatoryDescriptionGame verison
filenameString(tick)

The name of the file to include.

(question) If it's in a different folder, include the relative path?

3.1 Beta 1

Return value

In version 3.1 Beta 2 and earlier, this function would return undefined if the file was successfully loaded, however undefined is treated as false in an if statement, and false is the return value used to indicate the file failing to load!

As of 3.1 Beta 4 and above, the function will return true if the file was included, which is far easier to work with. However, if your script supports older versions of the game, then you need to be careful with earlier versions returning undefined instead of true.

ValueTypeDescriptionGame version
undefinedUndefined

The file was successfully included.

Note: undefined type-coerces to false in an if statement.

3.1 Betas 1 & 2 only
trueBooleanThe file was successfully included.3.1 Beta 4 and above
falseBooleanThere was a problem including the file.3.1 Beta 1

(info) The include() function traps any uncaught errors and writes them to the log files, then returns false. So you don't need to wrap this function in a "try ... catch" clause.

Example

Including a file
include("foo.js"); // include foo.js
  • No labels