needTime: body.length / 3
should be needTime: body.length * 3
Posts made by kirk
-
RE: creeps not spawning even though createCreep returned the provided creep name
-
RE: CPU log
@demos Check out the slack #help channel for quick answers to stuff like this. screeps.slack.com
-
RE: CPU log
@demos The game will only run code inside the "main loop" every tick. Code before that loop will run only once.
You'll want to move any "run every tick" to inside the main loop. In this case move your console.log statements. The
require
statements should stay outside the loop because they only need to load once.// This code runs only one time, when you push new code // or a reset happens on the server. module.exports.loop = function () { // This code runs every tick }
-
RE: StructureNuker is not a valid creep.withdraw() target.
The documentation update could be achieved with two sentences in italics below:
http://docs.screeps.com/api/#Creep.withdraw
Withdraw resources from a structure. The target has to be at adjacent square to the creep. Multiple creeps can withdraw from the same structure in the same tick. Your creeps can withdraw resources from hostile structures as well, in case if there is no hostile rampart on top of it. StructureNukers are an exception and cannot be withdrawn from.
http://docs.screeps.com/api/#StructureNuker
Launches a nuke to another room dealing huge damage to the landing area. Each launch has a cooldown and requires energy and ghodium resources. Launching creates a Nuke object at the target room position which is visible to any player until it is landed. Incoming nuke cannot be moved or cancelled. Nukes cannot be launched from or to novice rooms. Energy placed into a StructureNuker cannot be withdrawn.
-
StructureNuker is not a valid creep.withdraw() target.
The API documentation states that creep.withdraw() will: "Withdraw resources from a structure. "
But using .withdraw() on a STRUCTURE_NUKER results in an "invalid target" (-7) error.
I'd planned to use the 300k Energy in a nuker to rebuild a room that had its storage+terminal nuked. The undocumented invalidity of withdrawing from a Nuker left that room in pitiful shape until I could write more code.
So I'm requesting the API docs be updated to prevent this niche and unfortunate fate befalling others.
-
RE: Incorrect value using _.filter(..) to count creeps by role
Ahh, that makes sense. Thanks for the fix and the countBy suggestion!
-
Incorrect value using _.filter(..) to count creeps by role
I'm having a colony-killing error with this code to identify my creep population.
_.filter(Game.creeps, (creep) => creep.memory.role == 'miner').length
This line is regularly returning an incorrect 0-2 within a tick, when 10+ exist and are counted correctly when this line is pasted into the console. This is breaking my spawn logic and I end up overbuilding one role because of a false low value.
Is there an issue with counting creeps this way? What would work better?
Full code: https://gist.github.com/anonymous/a3438736a2303f71de9e5195547ccfefAfter a while it will start returning the correct value. (after my newb colony has gone off the rails) So this incorrect _.filter result hasn't been consistent.