Looking for info on the NEXUS faction in the game? It's in the Warzone Encyclopaedia
Classify Subroutines
Generates an "Object Key".
Purpose
You can use "Object Keys" to create a consistent way of describing the types and properties of objects you're working with.
A classify subroutine is responsible for providing the Object Key of a given object.
This is particularly useful when you use Object Keys as part of the TaskID. Let's say you classify a construction truck object as ".droid.construction" – if you use that as part of your task IDs, they'll look like this:
droidBuilt.droid.truck
objectSeen.droid.truck
attacked.droid.truck
destroyed.droid.truck
etc...
Some ready-made classify subroutines are shown to the right, they should be sufficient for most scenarios.
Build your own
A classify subroutine defines the NEXUS.classify() method – when passed an object it should return an "Object Key", which is a taxonomy path describing the object.
Your subroutine should be structured like this:
NEXUS.classify = (function() {
// /////////////////////////////////////////////////////////////////
// PRIVATE VARS
var chimp = "hairy"; // just an example :p
// /////////////////////////////////////////////////////////////////
// PUBLIC CLASSIFY FUNCTION
var classify = function(obj) {
// classify the object here to determine its "object key"
// up to you how to do that, take a look at existing mods for examples (:
return objKey; // objKey must be a string, ideally with "." at the start
}
// /////////////////////////////////////////////////////////////////
// PRIVATE FUNCTIONS
var isFoo = function(foo) { // just an example :p
return (foo != "bar");
}
// return your classify function
return classify;
})(); If you want to be super-helpful to other people looking at your code:
Make it easy to understand!
Show some sample classifications (or document them all!)
File name convention
Classify mods use the following naming convention: "NEXUS.classify_modName.js", where "modName" is the name of your mod.