Add function pointers to creep, not working. Help



  • I tried to add a function to the creep, but it seems not working, can anyone help me with this?

    Basicall I did:

    Game.creeps['Dylan'].memory.fn = function(){console.log('test');};

    but it does not show up in the memory watch, and I calling 

    Game.creeps['Dylan'].memory.fn() gives an error.

     

    THanks

     

     



  • You cannot add function to Memory. If you want to add logging ability to your creep please extend Creep prototype

     

    Creep.prototype.log = function(msg) {

        console.log(this.name + ' ' + msg);

    };

    // Then you can use this in your code

    Game.creeps['Dylan'].log('something');