Looking for info on the NEXUS faction in the game? It's in the Warzone Encyclopaedia
Process Subroutines
- Aubergine
Purpose
When a task is triggered, NEXUS performs a search to find an associated Action Object. For more information on how the search is performed, see The Concept.
Once an Action Object has been found, it's the job of a Process subroutine to perform the action.
Build your own
Commander, it is strongly recommended that you base any custom process subroutines on the standard NEXUS.process.js subroutine, as that subroutine handles everything that you can find in the Memory Banks.
A process subroutine defines the NEXUS.process() method. It will be passed the following parameters:
- task – the full name of the task that was called (taskName + objectKey + suffix)
- action – the action object associated with the task
- obj – the main object passed from the external event/function
- etc... – any additional data passed form the external event/function
Your subroutine should be structured like this:
NEXUS.process = (function() { // ///////////////////////////////////////////////////////////////// // PRIVATE VARS var chimp = "hairy"; // just an example :p // ///////////////////////////////////////////////////////////////// // PUBLIC PROCESS FUNCTION var process = function(task,action,obj,etc) { // process the event object // up to you how to do that, take a look at existing mods for examples (: // when processing functions, always wrap in a try..catch try { action.fn.apply(this,arguments); } catch(e) { console(task+" error:"+e.message); } // Return values can be: // * true = action performed, no further work // * false = action failed, no further work // * -1 = action performed, continue search return true; } // ///////////////////////////////////////////////////////////////// // PRIVATE FUNCTIONS var isFoo = function(foo) { // just an example :p return (foo != "bar"); } // return your process function return process; })();
If you want to be super-helpful to other people looking at your code:
- Make it easy to understand!
- Make it deal with common event handler object properties!
- Document deviations and differences compared to the standard NEXUS.process.js
File name convention
Process subroutines use the following naming convention: "NEXUS.process_modName.js", where "modName" is the name of your mod.
Subroutines
Absorb:
Memory Banks
Observe:
- Classify Subroutines — Generates an "Object Key".
- Fn Subroutines — Shared helper functions.
- Infiltrate Subroutines — Hook in to external events and functions.
- Process Subroutines — Process an "Action Object".
- Suffix Subroutines — Add a suffix to Task IDs.