Reputation: 5625
I have the following simple test module (called testModule
) in Screeps:
module.Exports = {
myProperty:'test'
};
In main
, I try to output the contents of the module like so:
var x = require('testModule');
console.log("Value:" + JSON.stringify(x));
But all I get is an empty object ({}
);
As a result, x.myProperty
is undefined. I have also tried making the module into a function, like so:
module.Exports = function(){
return {
myProperty:'test'
};
};
Then assigning it to x
with var x = require('testModule')();
but I get the same result.
Obviously the game is still in development, so it is possible that this is a bug, but I'd like to rule out a mistake on my part first. Anyone been able to achieve what I'm trying to do? Anyone see what I'm doing wrong?
Edit
Interestingly, it gives me the same empty object even if I change the module to this:
module.Exports = 'test';
Surely this should be printing the string 'test'
rather than an empty object? Is this a quirk of require js?
Upvotes: 1
Views: 281
Reputation: 5625
Just figured this out - I was using an uppercase E in module.exports
. I have corrected the case and now it works fine:
module.exports = {
myProperty:'test'
};
Upvotes: 3