replacing all instances of Game.creeps['creepName'].memory with Memory.creeps['creepName'] (i had hundreds of instances over all my modules) seems to have worked but i have lost the direct link between Game.creep and memory ... Does anyone know if it possible to rever my memory.root back to its original state?
Posts made by _BoB_
-
RE: HELP MEMORY BROKE pleas help quick
-
HELP MEMORY BROKE pleas help quick
I did something stupid. i deleted something unimportant in memory root, pressed save and clicked ok passed the warning not to, now all new creep that are made dont get saved to memory and so dont work at all.
-
RE: dismantle energy recovery?
Thanks :), i will try it with 4x WORK. Grrr i hate the Screeps API... I have just read the part about the 0.25 of 1 energy per tick. I originally thought the 0.25 was the fraction recovered from the energy used in creating/repairing the structure and proportional to the decrease in hits you cause a building relative to its total hits.. I did not think the 0.25 just relates to an arbitrary 1 energy, because that is not related to the amount of energy used to repair/construct the structure (maybe with the exception of walls). Also, the API states 2 different values for the fraction 0.25 (like you pointed out) and 50%/0.5. I really like this game, but for me the API documentation is just poor; it words some things very badly and can also be quite misleading (unintentionally). I understand it has had big changes recently which i have not really looked at much yet so maybe the API has been improved ~
quotes of the differing explanations from the same API reference page.
"Dismantles any (even hostile) structure returning 50% of the energy spent on its repair. Requires the
WORK
body part. If the creep has an emptyCARRY
body part, the energy is put into it; otherwise it is dropped on the ground. The target has to be at adjacent square to the creep.""Dismantles a structure for 50 hits per tick returning 0.25 energy unit per tick."
-
dismantle energy recovery?
So i read the API and it says you can recover a propotion of energy used to make/repair a structure by using a dismantle command.. But I don't seem to be getting any energy from dismantling buildings at all (no drops and no energy added to my creeps carry store). I have tried dismantling both a wall and enemy tower (in abandoned rooms), both got destroyed but neither dropped or gave me any energy. my creep has 3x work and 3x carry along with 6x move parts. the snippet from the code i use is bellow. Has this feature been taken out or am i doing something wrong?
if (creep.dismantle(enemyStruct[0]) == ERR_NOT_IN_RANGE) {
creep.moveTo(enemyStruct[0]);
} -
RE: why is _.filter not "working" in this situation???
Thank you ... you have been very helpful. Can't believe i have spent most of my day trying to understand why it was not working the way i was expecting.
-
RE: why is _.filter not "working" in this situation???
@cyberblast, thanks, that makes a lot of sense but then what exactly is the "filter:" doing different from the lodash "_.filter" version? is the "filter:" testing the structure hits before finding the closest structure or in parallel?
Stupid question, but what is the "filter:" called and is there any documentation on it so i can understand it better. Before screeps i had come across the lodash version but not the other.
could my statement/expression be altered for the lodash filter to fulfil the wanted function?
-
RE: why is _.filter not "working" in this situation???
Thanks for the quick response Rask Vann, but it still is not working. I am not getting any console errors, it just does not seem to have any effect. i cant work out why using "filter:" works but "_.filter" doesn't. what is the difference between them? i thought they were supposed to be pretty much equivalent?
-
why is _.filter not "working" in this situation???
this has driven me insane for the last couple of hours.
I was trying to get my towers to repair damaged structures with the following code
var towers = _.filter(Game.rooms.sim.find(FIND_STRUCTURES), (tower) => tower.structureType == STRUCTURE_TOWER);
for (var idx in towers){if(towers[idx]) {
var closestDamagedStructure = _.filter(towers[idx].pos.findClosestByRange(FIND_STRUCTURES), (structure) => structure.hits < structure.hitsMax);
if(closestDamagedStructure) {
towers[idx].repair(closestDamagedStructure);
}var closestHostile = towers[idx].pos.findClosestByRange(FIND_HOSTILE_CREEPS);
if(closestHostile) {
towers[idx].attack(closestHostile);
}
}but nothing happens (as in will not heal damaged structures), but when i change the filter from "_.filter" to "filter:" it works. I can not understand why "_.filter" does not work while "filter:" does?
WORKING: var closestDamagedStructure = towers[idx].pos.findClosestByRange(FIND_STRUCTURES, {filter: (structure) => structure.hits < structure.hitsMax});
NOT WORKING: var closestDamagedStructure = _.filter(towers[idx].pos.findClosestByRange(FIND_STRUCTURES), (structure) => structure.hits < structure.hitsMax);