So I am working on a small text based adventure game via node, I am using the SocketStream framework. What I want to do is to load a map via xml, parse that map, take each room from the map and store its information in a room object. I have made a room module that has all the required functions and variables for this.
What I am wondering is if this is the way to go about this and if it is how can I make a global array of room objects that I can access via other parts of the app.
Can I do the map loading, making rooms via the module and storing them in an array in the main app.js entry part? While this be accessible from the other parts of the app?
GLOBAL is the keyword for global variables. So in your case you can do something like
GLOBAL.rooms = rooms;
After this is done, in any other parts of the app, you can access the rooms like this
var rooms = GLOBAL.rooms;