Looking for info on the NEXUS faction in the game? It's in the Warzone Encyclopaedia

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 2 Next »

I will process tasks associated with events...

 

Purpose

Process subroutines determine how tasks are performed.

Transfer your own consciousness

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 an event key, including suffix if applicable, and one or more other parameters depending on the event that's being triggered.

The event key will already have been determined to exist in NEXUS.do object, so the process subroutine should:

  • Get the event handler object
  • Process the event handler object in the desired manner

Your mod should be structured like this:

NEXUS.process = (function() {
 
  // /////////////////////////////////////////////////////////////////
  // PRIVATE VARS

  var chimp = "hairy"; // just an example :p
 
  // /////////////////////////////////////////////////////////////////
  // PUBLIC PROCESS FUNCTION

  var process = function(eventKey,obj,etc) {
    // get the event handler object
    var data = this.do[eventKey];
 
    // 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 {
      data.fn.apply(this,arguments);
    } catch(e) {
      console(eventKey+" error:"+e.message);
    }
 
    return true; // true = processed successfully, false = failed
  }
 
  // /////////////////////////////////////////////////////////////////
  // 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:

  1. Make it easy to understand!
  2. Make it deal with common event handler object properties!
  3. 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.

My consciousness can only contain one process subroutine at a time.

Subroutines

Absorb:

Memory Banks

Observe:

 

  • No labels