Navigation

    forum

    • Login
    • Search
    • Categories
    • Recent
    • Popular
    • Users
    • Groups
    1. Home
    2. Soyaro
    • Flag Profile
    • block_user
    • Profile
    • Following
    • Followers
    • Topics
    • Posts
    • Groups
    • Blog

    Soyaro

    @Soyaro

    3
    Posts
    741
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online

    Soyaro Follow

    Posts made by Soyaro

    • RE: (not) building roads

      Fixed it by using Game.map.getRoomTerrain and if(terrain.get(buildx, buildy) == 0 || terrain.get(buildx, buildy) == 2)

      posted in Help
      Soyaro
    • RE: (not) building roads

      just changed the lines to the structure of

      var buildx = sources[poi].pos.x - 1 + roadx;
      

      Well, now it's trying to build the roads on 7 of the 8 spots so my logic must hav a mistake. A way more interesting problem is the game putting construction sites on the spawned barriers: 0_1602245653598_Screeps Roads.PNG What's going on there? 😕

      posted in Help
      Soyaro
    • (not) building roads

      Hi,

      I just started with the game, running simulations to test what I wrote so that I do have at least something going on when I release my creeps into the world.

      Now I wrote some code that doesn't do what I expect and I can't figure out why:

      var sources = Game.spawns[spawn].room.find(FIND_SOURCES);
      var newLength = sources.unshift(Game.spawns[spawn]);
      var newLength = sources.push(Game.rooms[name].controller);
      for(var i in towers) {
      	var newLength = sources.push(towers[i]);
      }
      for(var i in extenders) {
      	var newLength = sources.push(extenders[i]);
      }
      
      for(var poi in sources) {
      	for(var roadx = 0; roadx < 3; roadx++) {
      		for(var roady = 0; roady < 3; roady++) {
      			if(roadx == 1 && roady == 1) {
      				roady++;
      			} else {
      				var buildx = (sources[poi].x - 1 + roadx).valueOf();
      				var buildy = (sources[poi].y - 1 + roady).valueOf();
      				Game.spawns[spawn].room.createConstructionSite(buildx, buildy, STRUCTURE_ROAD);
      				Game.spawns[spawn].memory.lastbuild = Game.time + 100;
      				console.log('building Road at '+buildx+', '+buildy);
      			}
      		}
      	}
      }
      

      The expected behavior is to build roads around every source, the spawn, the controller, extenders and towers. The actual behavior is spamming "building Road at NaN, NaN" 8 times per sources.length (you know what I mean).

      What do I miss?

      posted in Help
      Soyaro