Accessing Game via global



  • I'm messing around with some code generation, and the framework I'm using requires global vars to be accessed via the global object, rather than directly. It seems like the global object exists, but it doesn't appear to contain a reference to Game as far as I can tell. Am I right in assuming Game can only be accessed directly, or is there a trick I can use instead of modifying my generated code?



  • As with any node environment, global does exist in screeps and is the global object. I put global.Game === Game into the console and got true. Perhaps something in the framework is messing it up. What framework are you trying to use?



  • aha! That helped me figure it out. Sure enough in World that's true, Game is a property of global. But it looks like in Simulation it isn't for some reason. Easy enough to work around for now knowing that it won't be a problem once I deploy to World. Thanks!