report(thing) {
var report = "";
report += "Report For "+ thing + "\n";
if (thing.structureType != null) {
report += "Type: STRUCTURE\n";
} else if ( thing instanceof Creep ) {
report += "Type: CREEP\n";
}
report += "ID: " + thing.id + "\n";
report += "---------------\n";
report += "STRINGIFIED:\n" + JSON.stringify(thing) + "\n";
report += "---------------\n";
console.log(report);
}
---------------
Report For [creep Kaelyn]
Type: CREEP
ID: 58841ace5f886cd81fe8c6a6
~~~~~~~~~~
STRINGIFIED:
{"room":{"name":"E75N2","mode":"world","energyAvailable":500,"energyCapacityAvailable":550},"pos":{"x":24,"y":14,"roomName":"E75N2"},"id":"58841ace5f886cd81fe8c6a6","name":"Kaelyn","body":[{"type":"work","hits":100},{"type":"carry","hits":100},{"type":"carry","hits":100},{"type":"move","hits":100},{"type":"move","hits":100}],"my":true,"owner":{"username":"MrC0de"},"spawning":false,"ticksToLive":1440,"carryCapacity":100,"carry":{"energy":2},"fatigue":0,"hits":500,"hitsMax":500}
~~~~~~~~~~
Thanks your answers all helped me along!
- Man from Future
MrC0de
@MrC0de
Posts made by MrC0de
-
RE: Allow us to access .type of objects
-
RE: Problems with finding containers
I was using
var roomContainers = Game.rooms[creep.room.name].find(FIND_MY_STRUCTURES, { filter: (structure) => { return ((structure.structureType == STRUCTURE_CONTAINER)) } });
console.log("Containers: "+ roomContainers.length);Apparently Containers arent in the MY.
Once I swapped to FIND_STRUCTURES it worked
-
Seeking Advice
Hello,
Just started screeps and hoping to work at for awhile. I put my current screeps on my github http://www.github.com/MrC0de and I am hoping folks can advise me on any topics they see as relevant. I am becoming increasingly concerned over the cpu spikes I see that I am pretty sure are my fault.
I'm basically collecting advice to ponder while optimizing later, looking for things to consider, feel free to bash my scripts I welcome your constructive criticism.