PTR Changelog 2015-11-27
-
API Changes
- Added
Creep.transfermethod. RemovedCreep.carry.*.transfer.Creep.transferEnergyis now an alias and considered deprecated. - Added
Creep.dropmethod. RemovedCreep.carry.*.drop.Creep.dropEnergyis now an alias and considered deprecated. - (Storage) Added
Structure.transfermethod. RemovedStructure.store.*.transfer.Structure.transferEnergyfor storages is now an alias and considered deprecated.
- Added
-
Those changes go definitely in the right direction. I am missing a
drop|transfer(RESOURCES_ALL)Maybe make theResourceTypeparameter optional and have it either default toallinstead (or have it default toenergyand add a constantRESOURCES_ALL)? Might be nice to have links being able to transfer power as well...
-
There is already undocumented
RESOURCES_ALLconstant. You can use it like that:RESOURCES_ALL.forEach(resourceType => creep.drop(resourceType));
-
Breaking change: Properties Creep.carry.energy and Structure.store.energy are now undefined when empty.
WHY???
now all comparisons like
creep.carry.capacity < creep.carryCapacityfail... Bad change imo! Is there a specific reason for that?
-
We'll have dozens of resource types in future, when mineral compounds appear. It'd be inconvenient to have defined variables for each of them in
carryandstore. However, we are considering the impact on backwards compatibility with players scripts due to this change right now, probably it will be a special case withenergyresource. This is PTR, so everything can be changed quickly.
-
@Artem Why can't I just say
creep.drop(RESOURCES_ALL)instead?
-
Why can't I just say creep.drop(RESOURCES_ALL) instead?
Because it won't be a clear API then. This method should be specified with exact types and optional amounts. What you really suggest is another method like
creep.dropAll().
-
Effectively, to determine if a creep is full you have to iterate over carry.
RESOURCES_ALL. This is tedious. There should be a general carry member likeamountdisplaying the total amount ofresourcea creep is carrying regardless the type.
-
I just realized, I already implemented this, when you introduced carry in the first place...

function isFull(){ return this.carryCapacity - _.reduce(this.carry) === 0; }
-
Yes, the total resources amount can be simply obtained by
_.sum(creep.carry), so there is no need in a separate property.
-
Could the transfer function be added to spawns and links if the transferEnergy function is going to be deprecated for storage?
-
OK, we have changed
carryandstoreto always includeenergy:0as an exceptional backward compatible case. All other resources will be undefined if empty.Could the transfer function be added to spawns and links if the transferEnergy function is going to be deprecated for storage?
It could, but spawns and links are not supposed to contain anything but energy.