How to get the transferred quantity with creep.transfer ?
-
Hello,
I'm trying to get the exact energy quantity transferred during a creep.transfer().
How can I get this value ?
I tried, without success :
energy_berfore = creep.carry.energy;
creep.transfer(...)
energy_after = creep.carry.energy;but both value before and after are always equals... So, it doesn't work !
-
After calling creep.transfer(...) the operation is just scheduled to be executed at the current tick (see engine descriptions, http://support.screeps.com/hc/en-us/articles/203032752-Understanding-game-loop-time-and-ticks), so inner states of all objects wont change until next tick.
Seems like the workaround (without exact amount specifying, 3rd argument) looks like:
let result = creep.transfer(obj, resource);
let transferred = result === OK ? Math.min(creep.carry[resource], /*obj.emptySpace*/) : 0;Dunno why u gonna do that, looks monstrous