creep.transfer not working properly



  • Newbie here. Can't seem to find a related post, but if there is, please point me to it.

    I have a harvester creep that attempts to transfer energy to my spawn when it is not at max capacity. When it calls creep.transfer(*my spawn here*, RESOURCE_ENERGY) but would add more energy to the spawn than it has capacity for, weird things happen.

    In one particular instance, the creep had 50 energy, the spawn had 263/300. The creep's energy decreased by 37, as it should, but the spawn's energy only increased by 10. I am certain that nothing else removed or used energy at the same time.

    In another instance the spawn's energy actually decreased by around 20. Again, nothing else used or otherwise changed the amount of energy in my spawn.

    Is there just something I'm missing? Because this seems more like a bug than a lack of understanding.

    EDIT: also, the creep does not do weird things when unable to unload all its energy. Even if it has 49/50 energy, it will still go find more energy before attempting to transfer again. Admittedly bad programming on my part, but at least its not part of the problem.


  • Dev Team

    Do you have a replay link to this behavior? Or a reproducible test case in the simulation?



  • Could you paste your code for the harvester?



  • I tracked down the first incident (where the spawn's energy only increased by 10) in the history. Somehow the creep both deposited its energy and renewed itself in the same tick. I didn't think this was possible, both in my code and in general, but it did, and I just didn't notice at the time.

    I assume something similar happened in the second instance, so I'm not going to track it down. Thanks, and sorry for taking your time.