Execute Function From Console?



  • Has anybody found a way to do this? I looked here but that doesn't seem to work any more. It throws an error.

    My function looks like this:

    module.exports = {
        doSomething: function(){
        }
    }
    

    and call it like this from the console:

    require('module').doSomething();
    

    which throws this error:

    SyntaxError: Unexpected identifier
        at n:5:28406
        at _console1439402269655_0:1:5491
        at Object.c.runCode:5:34055
    

    As far as I can tell it's exactly like the link above and should work. Any ideas?



  • Are you sure there is no syntax error in the module?



  • Just to clarify, if your module name is myModule then the console command is require('myModule').doSomethng();



  • @avdg_

    There was no syntax error but I was trying to declare a global or module variable to keep track of the different types of creeps but apparenly JS doesn't like that. I ended up using the Memory to track them.

    @DunknDonuts

    Yes, that's correct.