• I just got my control level to level 2, and I wanted to claim the room above me, so I made a claim creep with the body [MOVE, MOVE, CLAIM, CLAIM], I enter the room i want it to claim in its memory.room, and in my code, it uses that to move to the nearest exit to that room, and then try to claim the controller. However, its currently stuck on loop going back and fourth between them. And console.log dosnt even show me that its ever even in that room. I have it log the room trying to be claimed, and the room its in. and it just forever says E7N24, E7N23. and never changes, even though the creep visually goes to the other room.

    Mabey im doing something wrong?

    Shard 3 Room E7N23, trying to claim E7N24 (Don't mind the invader, ill deal with that, I'm just concerned about the problems above)

    my code 0_1626470935743_86045dc9-e4b6-41b1-8902-ef95ff339c29-image.png



  • This post is deleted!


  • Maybe you should add Game.time to the debug to check if your code runs every tick (it seems the most likely problem).

    You can also just moveTo destination controller position without travelling to the exit first.



  • Probably an issue caused by the walls. When using moveTo creeps will repath every time they enter a room. When pathing from within the room you're trying to claim it can "see" the walls and will attempt to avoid them. This path may then take it back into the original room where it'll repath while not being able to "see" the walls. This can kick you into an infinite loop.

    Lots of possible solutions. Using maxRooms: 1 as an option when you're in the target room is probably the easiest.



  • @tgdgnu I know it's not, because I had a console.log for every tick for it to log the room its in, and It always said the one room, it never changed, even though it visually went to the other room.

    And also, I tried to do that approach first, however, since I do not have any owned structures in that room, the controllers object isn't accessible from Game.rooms So I could't go creep.moveTo(Game.rooms[target].controller), because Game.rooms only returns my room

    Unless theres another way to get its object? Do I have to use its Id specifically? I was hoping theres de a way for me to just say, claim this room, and it just goes and does it, without me having to manually specify an id or whatever

    But i will if i must



  • It should be some kind of bug if the creep reports the wrong roomName while visually being in the other one. But more likely something is wrong in your code, so go for more debugging and post here a history link + debugging that you have done.

    You may test your code by manually specifying the position you want, like creep.moveTo(new RoomPosition(7,22,"E7N24"));

    or use creep.moveTo(new RoomPosition(25,25,"E7N24"),{range:24}) to just enter the room you want