I am having a hard time trying to figure out how to extend the creep class to add my own functions in the new javascript mmo game, Screeps -> www.screeps.com
How to extend the creep class in screeps
4.1k Views Asked by Ryan At
2
There are 2 best solutions below
1

A bit of an old thread, and I am not sure if Screeps has changed since the initial query was posted, but here are my thoughts...
Why have a wrapper class?? why not extend the original / game provided Creep class ?
e.g.
Creep.prototype.myFunction = function(target){
// my logic
}
Make sure to check out the screeps inheritance structure.. (Google the screeps API and check out the 'Prototypes' section on the landing page)
This can save a lot of duplicate code, for example one declaration of an inherited function in the 'Structure' prototype may save a seperate declaration for each individual Structure sub class protocols.
I dunno how to do that, but I created a wrapper class like this one:
You created a function for calling memory, and try to use it s property. See below: var _ = require("lodash");
So when I need to deal with creep, I do:
or
and then deal with myCreeps, locally stored.