You could call moveTo() first and then harvest() second, but the problem with that is, once your creep reaches the source, it will still call moveTo() on every tick. This will be a higher cpu cost, 0.2 cpu for harvest() and at least 0.2 cpu for moveTo(), for 0.4 cpu total. By checking for ERR_NOT_IN_RANGE and only doing the moveTo() in that case, it reduces your cpu cost to about 0.2 cpu total on every tick for this block of code. This is because when a method like harvest returns an error, it does not incur it's full constant 0.2 cpu cost, because the database is never written to.
Vultured
@Vultured
2
Posts
573
Profile views
0
Followers
0
Following
Posts made by Vultured
-
RE: Explanation ==ERR_NOT_IN_RANGE
-
RE: Holes in protected areas.
All of W50S10 to W40S10 is missing its wall. So is W50N0 to W41N0.