roleFixer not defined



  • I'm trying to make a creep to go around repairing structures, and I'm having this issue:

     

    I create a module

    role.fixer

    which has this:

    var roleFixer = {

    /** @param {Creep} creep **/
    run: function(creep) {

    //code to fix things
    }
    };

    module.exports = roleFixer;

     

    When I put the following in my main:

     

    if(creep.memory.role == 'fixer') {
    roleFixer.run(creep);
    }

    I get this error:

     

    ReferenceError: roleFixer is not defined
    at Object.module.exports.loop (main:59:13)
    at __mainLoop:1:52

     

    What am I doing wrong? The role.fixer module looks the same as my other roles, so I can't figure out why it's not 'defined'.



  • you seem to be missing your module importation in main.

    var roleFixer = require('role.fixer');



  • Thanks, yeah, I was missing that 'require' at the beginning of the main.