Welp, looked at my code and I had left it backwards. copied it from my harvesters' code and didn't switch true:false
module.exports = {
run: function(creep) {
if(creep.memory.working == true && creep.carry.energy == 0) {
creep.memory.working = false;
}
else if (creep.memory.working == false && creep.carry.energy == creep.carryCapacity) {
creep.memory.working = true;
}
if(creep.memory.working == true) {
var Container = creep.pos.findClosestByPath(FIND_STRUCTURES, {
filter: (s) => s.structureType == STRUCTURE_CONTAINER
&& s.store[RESOURCE_ENERGY] > 0
})
if(creep.withdraw(Container, RESOURCE_ENERGY) == ERR_NOT_IN_RANGE) {
creep.moveTo(Container)
}
}
else {
var EnergyStructures = creep.pos.findClosestByPath(FIND_STRUCTURES, {
filter: (s) => (s.structureType == STRUCTURE_SPAWN
|| s.structureType == STRUCTURE_EXTENSION)
&& s.energy < s.energyCapacity
})
if(creep.transfer(EnergyStructures) == ERR_NOT_IN_RANGE) {
creep.moveTo(EnergyStructures)
}
}
}
};
silly me
Posts made by HellWatcher
-
RE: [Resolved] Help with withdraw from container
-
[Resolved] Help with withdraw from container
So I'm trying to get move energy out of a container. I think the code I use returns -7 aka Invalid Target. I'm still new to coding.
Game.creeps[CreepName].withdraw(Game.rooms[RoomName].find(FIND_STRUCTURES, {filter: (s) => s.structureType == STRUCTURE_CONTAINER}), RESOURCE_ENERGY)
That is basically what I am trying to run. It targets the container correctly,
*Edit. That code is not what i was accually running but a failed attempt at debugging though the console instead of the script itself. <= Why I failed.....
-
RE: [Resolved] Massive script error
Thanks MyrddinE, I disabled every module and re-enabled them one at a time and found that for some reason screeps-profiler was causing the issue. I probably broke it. I'm not even close to actually benefiting from it. So, I will just leave it off.
  *Edit: Most likely it was how my defense acquired targets I had reverted to a working variant without realising. It takes a few minutes before the error shows up.
-
[Resolved] Massive script error
Hello everyone, I'm new to coding so debuging is hard still. I'm not sure what happened. I had not edited my scripts for a few minutes and out of nowhere the console spams this:
TypeError: Cannot read property 'message' of null
at Object.exports.evalCode (/opt/engine/dist/core/core.js:1350:14)
at Object.exports.runCode (/opt/engine/dist/game/game.js:483:22)
at connectPromise.then.then.e (/opt/engine/dist/core/runtime.js:156:18)
at _fulfilled (/opt/engine/dist/core/node_modules/q/q.js:834:54)
at self.promiseDispatch.done (/opt/engine/dist/core/node_modules/q/q.js:863:30)
at Promise.promise.promiseDispatch (/opt/engine/dist/core/node_modules/q/q.js:796:13)
at /opt/engine/dist/core/node_modules/q/q.js:604:44
at runSingle (/opt/engine/dist/core/node_modules/q/q.js:137:13)
at flush (/opt/engine/dist/core/node_modules/q/q.js:125:13)
at _combinedTickCallback (internal/process/next_tick.js:67:7)
at process._tickDomainCallback (internal/process/next_tick.js:122:9)I do not know what this error is from. can anyone help me?