PTR Changelog 2015-11-27
-
API Changes
- Added
Creep.transfer
method. RemovedCreep.carry.*.transfer
.Creep.transferEnergy
is now an alias and considered deprecated. - Added
Creep.drop
method. RemovedCreep.carry.*.drop
.Creep.dropEnergy
is now an alias and considered deprecated. - (Storage) Added
Structure.transfer
method. RemovedStructure.store.*.transfer
.Structure.transferEnergy
for 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 theResourceType
parameter optional and have it either default toall
instead (or have it default toenergy
and add a constantRESOURCES_ALL
)? Might be nice to have links being able to transfer power as well...
-
There is already undocumented
RESOURCES_ALL
constant. 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.carryCapacity
fail... 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
carry
andstore
. 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 withenergy
resource. 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 likeamount
displaying the total amount ofresource
a 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
carry
andstore
to always includeenergy:0
as 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.