Hi, i'm extremely new to javascript and therefore am probably asking a stupid question, but can you explain how you would call your function from within main?
So far, I've created a module called 'logs.test' and copied your code into this module.
from within main I can't seem to work out how to successfully call it and was hoping you could help?
All I see within the console is "Testing this function: undefined"
[main]
var Test = require('logs.test');
module.exports.loop = function () {
console.log('Testing this function: ' + Test());
...
}
[/main]
[logs.test]
module.exports = function(){
Room.prototype.stats = function(){
var foes = this.find(FIND_HOSTILE_CREEPS, {
filter: function(object) {
return object.getActiveBodyparts(ATTACK) == 0;
}
});
if (foes.length > 0){
return {
hostiles: foes,
numHostiles: foes.length,
hostileUser: foes[0].owner.username
};
} else {
return {
hostiles: foes,
numHostiles: 0,
hostileUser: undefined
}
}
}
};
[/logs.test]