Navigation

    forum

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

    Topics created by NanoCraft

    • Unsolved Setting creep spawn que priority order
      Help • • NanoCraft

      10
      10
      Posts
      12703
      Views

      @mrfaul Before i read it (again), when you say that the priority is from bottom to top, do you mean that the bottom has the least priority and the top has the most? This is how i understand it, but thought you were saying the opposite: if(true){ //do 1 }else if(true){ //do 2 }else if(true){ //do 3 } //.... For me, in this example, "1" has the highest piority and that's why it's checked first, and bottom ("3"), has the least and that's why it's at the bottom. This is the logic i followed to spawn creeps: The most important roles like haulers or miners at the top. EDIT: @MrFaul Now i finally understand what you meant when you said the priority was from bottom to top, and why i solved it without even being conscious about it. @W4rl0ck made me realize when he told me that.... ... but if you have two calls calling to spawn a creep on the same spawn the last one will get executed.
    • Solved Transferring energy to storage
      Help • • NanoCraft

      5
      5
      Posts
      11594
      Views

      @wtfrank @Saruss @famine Thanks a lot for the explanation guys now I understand why it is different and the code is working all good also.
    • Unsolved Harvesting from multiple sources within a room
      Help • • NanoCraft

      8
      8
      Posts
      21384
      Views

      @famine Thanks for pointing me in the right direction, I used let. The code is a bit-long winded - I am surprised it worked tbh - but it did run: function(creep) { let prospect = new RoomPosition(34,4, 'W57S45'); let home = new RoomPosition(16,34, 'W57S44'); if(creep.memory.prospecting && (!creep.pos.isNearTo(prospect) || creep.carry.energy === creep.carryCapacity)) { creep.memory.prospecting = false; creep.say('⛏ seeking'); } if(!creep.memory.prospecting && (creep.carry.energy < creep.carryCapacity && creep.pos.isNearTo(prospect))) { creep.memory.prospecting = true; creep.say('Container'); } if(creep.memory.prospecting) { var sources = creep.room.find(FIND_SOURCES); if(creep.harvest(sources[0]) == ERR_NOT_IN_RANGE) { creep.moveTo(sources[0], {visualizePathStyle: {stroke: '#ffaa00'}}); } } if(!creep.memory.prospecting && creep.carry.energy < creep.carryCapacity) { creep.moveTo(prospect) } else if (!creep.memory.prospecting && creep.carry.energy === creep.carryCapacity) { creep.moveTo(home); var targets = creep.pos.findClosestByPath(FIND_STRUCTURES, { filter: (s) => (s.structureType == STRUCTURE_CONTAINER || s.structureType == STRUCTURE_STORAGE) && s.store.energy < s.storeCapacity }); if(targets) { if(creep.transfer(targets, RESOURCE_ENERGY) == ERR_NOT_IN_RANGE) { creep.moveTo(targets, {visualizePathStyle: {stroke: '#ffffff'}}); } } }