This AI is still in early stages of development.
Check.doWhen()
- Aubergine
Syntax
Check.doWhen(dependencies, sdo, task[, lazy]);
Parameters
Parameter | Type | Mandatory | Notes | Util.js version |
---|---|---|---|---|
dependencies | Dependency Descriptor Object | The dependencies for the task. | 1.0 | |
sdo | The SDO of the script submitting the task. | 1.0 | ||
task | Function String | Either:
Note: Autoloading must be enabled if you specify a file name to load. See Check.paths[] for more information. | 1.0 | |
lazy | Constant | By default, Check.doWhen() will attempt to autoload missing dependencies (except those marked as If you want to prevent autoloading, specify See Check.paths[] for more information on autoloading. | 1.0 |
Return Values
Value | Type | Notes | Util.js version |
---|---|---|---|
true | Boolean | The dependencies were available and the task has been performed. | 1.0 |
false | Boolean | One or more of the dependency checks failed and the task has not yet been performed. The task will be queued until missing dependencies become available. If one of the dependencies is marked as | 1.0 |
<error> | Error | An error occurred, usually due to one of the following reasons:
| 1.0 |
Notes
The Check.doWhen() function is most commonly used for lazy loading diagnostic routines and unit tests, neither of which are not required for normal gameplay.
You can use the "loaddiag
" or "loadtest
" chat commands (part of Chat API) to load Diag API or Test API, as applicable, at any time during a game, which in turn will cause all the associated lazy-load scripts to be loaded.
You can run the "blocked
" diagnostic (requires Diag API) to get a list of tasks that are blocked due to errors or presence of dependencies marked as Check.NOT_LOADED
. You can also run the "blocked
" diagnostic routine via the "diag blocked
" chat command (requires Chat API).
Example
Note: In these examples, it's assumed the 'self' variable is already defined. For more information on that variable, see Self Descriptor Object.
Check.doWhen( {"Diag.js": true}, self, "Diag.Cache.js", Check.LAZY_LOAD );
Check.doWhen( {"Chat.js": true}, self, function() { chat(0, "Let's chat..."); }, Check.LAZY_LOAD );
Contents
Jump to:
Dependency Checking
Topics:
- Tricks for including files — Some tricks with the include() function...
- Dependency Descriptor Object — Define one or more dependencies for your script...
- Check() — Perform a soft-check to see if a dependency is available...
- Check.basePath — The base path to the folder that contains the APIs folder...
- Check.paths[] — Define one or more folder paths to enable autoloading...
- Check.doWhen() — Perform a task when dependencies become available.
- Check.has() — Check if a dependency is available, try and load it if not, return availability state...
- Check.LAZY_LOAD — Disable autoloading during a dependency check...
- Check.required() — Thrown a descriptive error if dependency check fails...
- Check.NOT_LOADED — Indicates a script is not yet loaded, or must not be loaded, depending on the Check function being used...
- Check.ANY_VERSION — Skip version checking for a dependency check...
- Check.provide() — Indicate a file is now available.
- Check.versionOf() — Check the version of a dependency.
- Self Descriptor Object — Define the filename and version of your script...