@mrfaul no it doesn't work )))))))))))))))) https://pastebin.com/AgCJZ4y6
kepamuk
@kepamuk
Posts made by kepamuk
-
RE: Two same objects show different result
-
RE: Two same objects show different result
@mrfaul I started to count differently and the problem is the same, with the old way everything is fine, with the new problem)))))))) can say why?)))))
const createRoles = {}; for (const i in rolesRoom.rooms) { createRoles[rolesRoom.rooms[i].name] = rolesRoom.levels[rolesRoom.rooms[i].level]; } const roles = createRoles; // const roles = rolesRoom.role; // console.log(JSON.stringify(roles)) // подсчитываем количество крипов в руме for (const spawnRoom in roles) { for (const roleName in roles[spawnRoom]) { roles[spawnRoom][roleName].currentQuantity = 0; } } for (const i in Game.creeps) { const creep = Game.creeps[i]; roles[creep.memory.spawnRoom][creep.memory.role].currentQuantity += 1; if (creep.memory.spawnRoom === 'E59S58' && creep.memory.role === 'upgrader') { // console.log(creep.memory.spawnRoom) // console.log(creep.memory.role) console.log(creep) // we only come here once } } console.log(roles['E59S58']['upgrader'].currentQuantity) // here 4 why ?????????????
-
RE: Two same objects show different result
@mrfaul ok then i try to change my code ! thank you
-
RE: Two same objects show different result
@smokeman here you can see the objects are completely identical, but show different results
I was thinking if you have the opportunity, maybe you could look with teamviawer?
-
RE: Two same objects show different result
@smokeman said in Two same objects show different result:
Meaning roleRoom.rooms is an array, not an object. Sure, the overall container it's in is an object... but rooms is an array. So you use the of iterator, like: for (const i of rolesRoom.rooms)
I did so and the result is the same
for (const obj of rolesRoom.rooms) { createRoles[obj.name] = rolesRoom.levels[obj.level]; }
To be honest? I could feel myself descending into madness just trying to figure out what that code does. It could probably be a lot simpler. Not that I'm judging... I've certainly written code I've looked at later and wondered what was going on.
sorry but I'm just learning)) I think it's better than nothing
-
RE: Two same objects show different result
@mrfaul said in Two same objects show different result:
"But are you sure you don't have any creeps that get counted?";
of course there are no creeps you see in cycle 0 itself, but when outside the cycle this field shows 1