Overview
Enables additional javascript files to be included in your script.Availability
Warzone 3.1 Beta 1 and above. Improved in 3.1 Beta 4.
Syntax
var returnValue = include("path/filename.js");
Parameters
Parameter | Type | Mandatory | Description | Game verison |
---|---|---|---|---|
"path/filename" | String | The path to the file that should be included. The path starts at your mod folder. For example, if you're writing an AI script and want to include a "whatever.js" script that's stored in the same folder as your AI script, you'd specify:
Even though whatever.js is in the same folder as your AI script, you still need to specify the path to it! | 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
.
Value | Type | Description | Game version |
---|---|---|---|
undefined | Undefined | The file was successfully included. Note: | 3.1 Betas 1 & 2 only |
true | Boolean | The file was successfully included. | 3.1 Beta 4 and above |
false | Boolean | There was a problem including the file. | 3.1 Beta 1 |
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
include("foo.js"); // include foo.js