Yeah, it does work fine on the MMO. I quess I'll stick to that then. Thanks again
Posts made by Darth_Duck
-
RE: Memory resets every tick in simulation
-
RE: Memory resets every tick in simulation
@Donatzor Many thanks for your reply.
Exiting the function early is a crazy good idea. Thanks:)
Unfortunately, it didn't solve the memory issue. There are no lines of code between the last line in the main loop and the first. Still, the memory is gone. I'll go ahead and check out discord as well.
function newGameSetup() { if (Memory.firstSpawnId === Game.spawns['Spawn1'].id) { return; } console.log('Setting up new game') var spawnPlaced = false; while (!spawnPlaced) { if (Object.keys(Game.spawns).length) { spawnPlaced = true; } } Memory = { squads: {}, creeps: {}, spawns: {}, rooms: {}, firstSpawnId: Game.spawns['Spawn1'].id }; } module.exports.loop = function () { console.log('Memory begin of game loop: ' + JSON.stringify(Memory)); newGameSetup(); console.log('Memory end of game loop: ' + JSON.stringify(Memory)); }
[4:54:59 PM]Memory begin of game loop: {"creeps":{},"spawns":{},"rooms":{},"flags":{}} [4:54:59 PM]Setting up new game [4:54:59 PM]Memory end of game loop: {"squads":{},"creeps":{},"spawns":{},"rooms":{},"firstSpawnId":"3225a929cc7310e6abcee4e9"} [4:55:00 PM]Memory begin of game loop: {"creeps":{},"spawns":{},"rooms":{},"flags":{}} [4:55:00 PM]Setting up new game [4:55:00 PM]Memory end of game loop: {"squads":{},"creeps":{},"spawns":{},"rooms":{},"firstSpawnId":"3225a929cc7310e6abcee4e9"} [4:55:01 PM]Memory begin of game loop: {"creeps":{},"spawns":{},"rooms":{},"flags":{}} [4:55:01 PM]Setting up new game [4:55:01 PM]Memory end of game loop: {"squads":{},"creeps":{},"spawns":{},"rooms":{},"firstSpawnId":"3225a929cc7310e6abcee4e9"} [4:55:02 PM]Memory begin of game loop: {"creeps":{},"spawns":{},"rooms":{},"flags":{}} [4:55:02 PM]Setting up new game [4:55:02 PM]Memory end of game loop: {"squads":{},"creeps":{},"spawns":{},"rooms":{},"firstSpawnId":"3225a929cc7310e6abcee4e9"}
-
Memory resets every tick in simulation
Hi,
I've started out on a live server and made some code to detect when I respawn. This worked OK, but then I wanted to try the simulation and it looks like the memory gets reset every tick. I've cut down the code to the bare minimum and I still don't see the problem. Could someone have a look at my code and point me in the right direction?
Full code:
function newGameSetup() { var newGame = false; if (Memory.firstSpawnId != Game.spawns['Spawn1'].id) { newGame = true; } if (newGame) { console.log('Setting up new game') var spawnPlaced = false; while (!spawnPlaced) { if (Object.keys(Game.spawns).length) { spawnPlaced = true; newGame = false; } } Memory = { squads: {}, creeps: {}, spawns: {}, rooms: {}, firstSpawnId: Game.spawns['Spawn1'].id }; } } module.exports.loop = function () { console.log('Memory begin of game loop: ' + JSON.stringify(Memory)); newGameSetup(); console.log('Memory end of game loop: ' + JSON.stringify(Memory)); }
Console logging:
[3:28:56 PM]Memory begin of game loop: {"creeps":{},"spawns":{},"rooms":{},"flags":{}} [3:28:56 PM]Setting up new game [3:28:56 PM]Memory end of game loop: {"squads":{},"creeps":{},"spawns":{},"rooms":{},"firstSpawnId":"b2d9f725ca04df4c66c41f23"} [3:28:57 PM]Memory begin of game loop: {"creeps":{},"spawns":{},"rooms":{},"flags":{}} [3:28:57 PM]Setting up new game [3:28:57 PM]Memory end of game loop: {"squads":{},"creeps":{},"spawns":{},"rooms":{},"firstSpawnId":"b2d9f725ca04df4c66c41f23"} [3:28:58 PM]Memory begin of game loop: {"creeps":{},"spawns":{},"rooms":{},"flags":{}} [3:28:58 PM]Setting up new game [3:28:58 PM]Memory end of game loop: {"squads":{},"creeps":{},"spawns":{},"rooms":{},"firstSpawnId":"b2d9f725ca04df4c66c41f23"} [3:28:59 PM]Memory begin of game loop: {"creeps":{},"spawns":{},"rooms":{},"flags":{}} [3:28:59 PM]Setting up new game [3:28:59 PM]Memory end of game loop: {"squads":{},"creeps":{},"spawns":{},"rooms":{},"firstSpawnId":"b2d9f725ca04df4c66c41f23"} [3:29:00 PM]Memory begin of game loop: {"creeps":{},"spawns":{},"rooms":{},"flags":{}} [3:29:00 PM]Setting up new game [3:29:00 PM]Memory end of game loop: {"squads":{},"creeps":{},"spawns":{},"rooms":{},"firstSpawnId":"b2d9f725ca04df4c66c41f23"}