Renaming creeps
-
How would i rename i creep i thought it would be something like this
Game.creeps.B-0.Name = 'B0';
-
i noticed that all the harvesters named W-(#) and with a harvester role stopped moving
and the ones without are normal!
-
- You can't rename creep. Usually it is easier to wait until it ages and die and born another one with the right name.
- You can't access creep with '-' in the name that way (because it is minus operation sight in JavaScript), but you can do it like Game.creeps['B-0']
- It is better not to use creep names in your logic. Use creep.memory instead.
-
- sight = sign
-
thanks for the info @xoposhiy
also could you give me an example of using creep.memory that i'd love to learn!
i'm currently learning JS in code academy and applying what I learn here. I'm improving slowly but surely!
-
scratch that would this be an example
Memory.creeps."W0".role = 'harvester');
-
for(var name in Game.creeps){ var creep = Game.creeps[name]; if (creep.memory.role == 'harvester') { ... } else if (creep.memory.role == 'builder') { ... } ... }