Maybe is my just my computer broken? Here's a video I recorded:
Thanks in advance!
Edit: It happens in the steam version
Maybe is my just my computer broken? Here's a video I recorded:
Thanks in advance!
Edit: It happens in the steam version
thanks everyone, I forgot that silly thing. Problem solved
Cannot read property "controller" of undefined, the code is the following:
function getRandomInt(max) {
return Math.floor(Math.random() * Math.floor(max));
}
function getRoomName(NameOfTheRoom){
let Yletter = 'S';
let Ycoord;
let Xletter = 'E';
let Xcoord;
let roomDescomposed;
let numY = NameOfTheRoom.split("S");
if(numY.length == 1){
Yletter = 'N';
numY = NameOfTheRoom.split("N");
}
let numX = numY[0].split('E');
if(numX.length == 1){
Xletter = 'W';
numX = numY[0].split("W");
}
Ycoord = numY[1];
Xcoord = numX[1];
roomDescomposed = [Xletter, Xcoord, Yletter, Ycoord];
return roomDescomposed;
}
function getRandomRoom(roomArray, limit){
let newRoom = roomArray;
if(getRandomInt(2) == 0){
newRoom[1] = Number(roomArray[1])+getRandomInt(limit + 1);
newRoom[3] = Number(roomArray[3])+getRandomInt(limit + 1);
}
else{
newRoom[1] = Number(roomArray[1])-getRandomInt(limit + 1);
newRoom[3] = Number(roomArray[3])-getRandomInt(limit + 1);
}
if(newRoom[1] < 0){
newRoom[1] = Math.abs(newRoom[1]);
if(newRoom[0] == 'E'){
newRoom[0] = 'W';
}
else{
newRoom[0] = 'E';
}
}
if(newRoom[3] < 0){
newRoom[3] = Math.abs(newRoom[3]);
if(newRoom[2] == 'N'){
newRoom[2] = 'S';
}
else{
newRoom[2] = 'N';
}
}
newRoom = (newRoom[0]+newRoom[1]+newRoom[2]+newRoom[3]).toString();
console.log(newRoom); //here it returns the name of the room correctly v(ยท_ยท)v
if(Game.rooms[newRoom].controller.reservation.my || Game.rooms[newRoom].controller.my){
newRoom = undefined;
}
return newRoom;
}
creep.memory.MyRoom = getRoomName(creep.room.name);
if(creep.memory.target == undefined || creep.memory.target == creep.memory.MyRoom){
creep.memory.target = getRandomRoom(creep.memory.MyRoom, 3);
Is there a Discord server or something? I'm really curious abot that. Thanks
@tehfiend That's easier, thanks!
@geir1983 Ok, so I don't have enough gcl, do you know how can I increase it? I'm kinda noob
So the creep moves towards the controller, but then it stands still without claiming it... This is the code
var roleClaimer = {
run: function(creep) {
creep.memory.target = 'E1S42';
if(creep.room.name != creep.memory.target){
var getMeOut = creep.room.findExitTo(creep.memory.target);
creep.moveTo(creep.pos.findClosestByRange(getMeOut));
}
else{
creep.moveTo(creep.room.controller);
creep.claimController(creep.room.controller);
}
}
};
module.exports = roleClaimer;
The creep starts moving the wrong direction and goes into another room. Then it stands still.
var roleScout = {
run: function(creep) {
creep.memory.target = ('E1S46');
if(creep.room.name != creep.memory.target){
var getMeOut = creep.room.findExitTo(creep.memory.target);
creep.moveTo(creep.pos.findClosestByRange(getMeOut));
creep.say(':D ?');
}
else{
creep.moveTo(creep.room.controller);
}
}
}
module.exports = roleScout;
Any idea?
@donatzor And... It worked!! Thanks a lot!!!!!
It's a code for role.builder module, I was trying to get him to repair ramparts when built, so they wouldn't be destroyed, but it doesn't work. Is there anything you can see here?
var roleBuilder = {
run: function(creep) {
if(creep.memory.building && creep.store[RESOURCE_ENERGY] == 0) {
creep.memory.building = false;
creep.say('ENERGY');
}
if(!creep.memory.building && creep.store.getFreeCapacity() != creep.store.getCapacity()) {
creep.memory.building = true;
creep.say('WORK');
}
if(creep.memory.building == true) {
if(creep.memory.repairing == false){
var targets = creep.room.find(FIND_CONSTRUCTION_SITES);
if(targets.length) {
if(creep.build(targets[0]) == ERR_NOT_IN_RANGE) {
creep.moveTo(targets[0], {visualizePathStyle: {stroke: '#ffffff'}});
}
}
var important = creep.room.find(FIND_STRUCTURES, {
filter: (s) => s.hits < 2 && s.structureType == STRUCTURE_RAMPART
});
if(important != undefined){
creep.memory.repairing = true;
}
}
else{
if(creep.repair(important) == ERR_NOT_IN_RANGE){
creep.moveTo(important, {visualizePathStyle: {stroke: '#ffffff'}});
}
}
}
else {
creep.memory.repairing = false;
let container = creep.room.find(FIND_STRUCTURES, {
filter: s => s.structureType == STRUCTURE_CONTAINER && s.store[RESOURCE_ENERGY] > 0
});
if (container.length > 0) {
if (creep.withdraw(container[0], RESOURCE_ENERGY) == ERR_NOT_IN_RANGE) {
creep.moveTo(container[0]);
}
}
}
}
};
module.exports = roleBuilder;