What am I doing wrong here? I define a variable in FILE1, then require FILE1 in FILE2, and I require FILE2 in MAIN, so I expected to be able to access the global var my_global
from both MAIN and FILE2 but it throws an error.
FILE1
var my_global=42;
FILE2
require('FILE1');
var harvesterCount=12;
console.log(harvesterCount+my_global); //throws error
module.exports = function () {...}
MAIN
require('FILE2');
console.log(my_global); //error here
The error statement (from Screeps console):
ReferenceError: my_global is not defined
at module.exports:8:5
at Object.module.exports.loop:6:5
at __mainLoop:1:12057
at eval:2:4
at Object.c.runCode:6:26869