Navigation

    forum

    • Login
    • Search
    • Categories
    • Recent
    • Popular
    • Users
    • Groups
    1. Home
    2. kepamuk
    • Flag Profile
    • block_user
    • Profile
    • Following
    • Followers
    • Topics
    • Posts
    • Groups
    • Blog

    kepamuk

    @kepamuk

    14
    Posts
    1111
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online

    kepamuk Follow

    Posts made by kepamuk

    • RE: Two same objects show different result

      @mrfaul no it doesn't work )))))))))))))))) https://pastebin.com/AgCJZ4y6

      posted in Help
      kepamuk
    • RE: Two same objects show different result

      alt text alt text

      posted in Help
      kepamuk
    • 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?)))))

      alt text

      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 ?????????????
      posted in Help
      kepamuk
    • RE: Two same objects show different result

      @mrfaul ok then i try to change my code ! thank you

      posted in Help
      kepamuk
    • RE: Two same objects show different result

      @smokeman alt text 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?

      posted in Help
      kepamuk
    • RE: Two same objects show different result

      @mrfaul Here: alt text

      When I comment this "console.log("Test for creep: ",c.name," is ",toString(test)); "

      alt text

      posted in Help
      kepamuk
    • RE: Two same objects show different result

      maybe another ideas ?

      posted in Help
      kepamuk
    • RE: Two same objects show different result

      @smokeman alt text

      alt text

      posted in Help
      kepamuk
    • 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

      posted in Help
      kepamuk
    • 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

      posted in Help
      kepamuk