oh, wow. Thank you ;X
Bodda
@Bodda
Posts made by Bodda
-
Problem with lab code (role.scientist)
Hey guys, I'm trying to write a transport creep that fills the labs with minerals, but after a lot of changing my code around, it's still not working. I changed it around a lot, but this is my current code:
```javascript
} else if (creep.memory.order == 'Sc') {
var labL = Game.getObjectById('57af7bca736eb18b5f3b76e2');
var labH = Game.getObjectById('57b02ee949ae38c432e9d225');
var total = _.sum(creep.carry);
if (labL.mineralAmount == 0) {
//GET LEMERGIUM FROM STORAGE
if (creep.carry[RESOURCE_LEMERGIUM] == 0) {
if(creep.withdraw(creep.room.storage, RESOURCE_LEMERGIUM) == ERR_NOT_IN_RANGE) {
creep.moveTo(creep.room.storage);
}
} else {
if (creep.transfer(labL) == ERR_NOT_IN_RANGE) {
creep.moveTo(labL);
}
}
} else if (labH.mineralAmount == 0) {
//GET HYDROGEN FROM TERMINAL
if (creep.carry[RESOURCE_HYDROGEN] == 0) {
if(creep.withdraw(creep.room.terminal, RESOURCE_HYDROGEN) == ERR_NOT_IN_RANGE) {
creep.moveTo(creep.room.terminal);
}
} else {
if (creep.transfer(labH) == ERR_NOT_IN_RANGE) {
creep.moveTo(labH);
}
}
} else {```
The creep is just standing around after spawning and does nothing. I got it to pick up some L at some point, but it didn't transport it but now it doesn't move at all again. PLEASE help I need my labs working^^
Thanks guys!
-
RE: Simulator Feature Request
I agree. just add options to add another room and controller and stuff that would be really great
-
Help with eserving multiple rooms - creep.reserveController
Hey guys, I'm having trouble with my reserver creep, which is supposed to move to a target room and then reserve the controller in that room. Currently, it gets to the target room, and then it switches back to the romm before that, and then it keeps switching.
This is my code for the reserver unit:
var roleReserver = {
/** @param {Creep} creep **/
run: function(creep) {
//MOVE TO TARGET ROOM
if(creep.room != 'E44S19') {
var route = Game.map.findRoute(creep.room, 'E44S19');
if(route.length > 0) {
var exit = creep.pos.findClosestByRange(route[0].exit);
creep.moveTo(exit);
}
}
//RESERVE CONTROLLER IN TARGET ROOM (NOT WORKING, CREEP IS SWITCHING BETWEEN TARGET ROM AND THE ONE BEFORE THAT)
else {
if(creep.room.controller) {
if(creep.reserveController(creep.room.controller) == ERR_NOT_IN_RANGE) {
creep.moveTo(creep.room.controller);
}
}
}
}
}
module.exports = roleReserver;I think the Problem is either, it can't get the controller because I don't own the room, or, the creep doesn't actually get the order to move to the controller for some reason. I have noticed, that in creep.reserveController(creep.room.controller); the reserveController part doesn't actually markup in yellow, so I'm not sure if it's working, but I copy/pasted it from the dpcumentation, so... any help? Basically what I want is be able to tell it which room to reserve when it's spawned, so it's easy to use for multiple rooms.
Thanks in advance for your answers
Edit: I got it to work now, but reserveController is still not yellow O_o, Maybe move to bug forum? or is it a local problem with the markup? I didn't change anything for that
-
RE: Only pick up energy?
Thank you for the quick answer, I will try that now. It's weird though, it doesn't show up in yellow in my markup.
-
Only pick up energy?
Hey guys!
So, I have my creeps pick up droppen energy, so it's not lost when a creep dies or when invaders drop energy. now. sometime the invaders are boosted and have these combined minerals on them, which I had one time picked up by a creep, which then went on and mined forever, beavause it couldn't fill the whole capacity with energy, as there was already some minerals there that took up space. This is my code for the pickup:
var dropenergy = creep.pos.findClosestByPath(FIND_DROPPED_ENERGY, {
filter: (d) => {return (d.mineralType == RESOURCE_ENERGY)}});
if (dropenergy) {
if (creep.pickup(dropenergy) == ERR_NOT_IN_RANGE) {
creep.moveTo(dropenergy)
}
}else {
//harvest if no dropped energy
var sources = creep.room.find(FIND_SOURCES);
if(creep.harvest(sources[0]) == ERR_NOT_IN_RANGE) {
creep.moveTo(sources[0]);
}
}I added the filter to try and do it, but now it doesn't pick up anything. without the filter, it picked up everything. I also included the code for harvesting afterwards.
#
edit: also, how do I post code here with markup and stuff?
-
RE: How i can control second room?
Hey guys,
I'm sorry to bring this up again, but I have a question about this topic, too.
so, assuming I do the stuff in the main loop so it works for any room. e.g. assigning creep roles managing tower and stuff. I would only need to make a seperate autospawn for a second spawner, but I don't have that yet anyway, as my controller just got lo lvl 4.
SO, I would need to make it so my creeps I want there only ever work in one room, and if they are not there, then move to that room.
My question is if functions like find(MY_STRUCTURES) search only one room.
or like this, so does this do it for the current room of the creep?
if(creep.upgradeController(creep.room.controller) == ERR_NOT_IN_RANGE) {
creep.moveTo(creep.room.controller);
}I'm kind of wondering about the basics of multirooms. also without using too much extra cpu, beacause I see some ppl with many many rooms and I'm spiking to 7 or 13 sometimes with just 1 room.
-
RE: I need help with a few things
Thank you guys, I got it to work now. Maybe I just didn't see it repairing beacause I just watched the replay back, I wasn't actually there when it happened. Anyway, I put the tower code right after the memory clearing in the main loop, and I made it so that it checks for hostiles before it starts repairing. Also, my builders are now repairing as well, when they don't have anything to build.
For the problem with the 2 sources, I just made it so my building guy Uses one of them, which only has 1 spot anyway. Not sure how I'll solve that with multiple rooms though, but I think that's some time away anyway If you have any tips on managing harvesters in a second room though, feel free to share them
-
I need help with a few things
Hey guys, I really like the game, but I've got a few problems I need some help with. First of all, my harvesters are just using one of my sources (my room has 2) and I can't get them to use both. this is my code for that:
[code]
if(creep.carry.energy < creep.carryCapacity) {
var sources = creep.room.find(FIND_SOURCES_ACTIVE);
if(creep.harvest(sources[0]) == ERR_NOT_IN_RANGE) {
creep.moveTo(sources[0]);
}
}[/code]
also, in my last room I got attacked by another player, and my tower didn't attack at all. after watching it back (i wasn't there at the time), I noticed, that it didn't repair my roads and stuff anymore, either. It just stopped working for some reason. This is my tower code:
[code]
var tower = Game.getObjectById('577ddb750cb165f62157b3db');
if(tower) {
var closestDamagedWall = tower.pos.findClosestByRange(FIND_STRUCTURES, {
filter: (structure) => structure.hits < structure.hitsMax / 3000 && structure.structureType == STRUCTURE_WALL || structure.structureType == STRUCTURE_CONTAINER || structure.structureType == STRUCTURE_RAMPART
});
var closestDamagedRoad = tower.pos.findClosestByRange(FIND_STRUCTURES, {
filter: (structure) => structure.hits < structure.hitsMax && structure.structureType == STRUCTURE_ROAD
});
if(closestDamagedWall) {
tower.repair(closestDamagedWall);
}
else {
tower.repair(closestDamagedRoad);
}
var closestHostile = tower.pos.findClosestByRange(FIND_HOSTILE_CREEPS);
if(closestHostile) {
tower.attack(closestHostile);
}
}[/code]
I checked the ID, it was definitely correct. I don't see why this isn't working, please help