Navigation

    forum

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

    Topics created by EPICBRONY

    • creep is not defined?
      Help • • EPICBRONY

      2
      2
      Posts
      4670
      Views

      Is this all there is in your main? If so, how would it know what creep to check? You need to iterate over all the creeps in order to do this. So, make loop that loops over Game.creeps and in that loop, run what you have now. (P.S. You stole the room I wanted to expand to :P)
    • What is wrong with my script?
      Help • • EPICBRONY

      4
      4
      Posts
      6737
      Views

      now with this code ~~~ var harvester = require('harvester'); if (creep.memory.role == 'harvester') { if(creep.carry.energy < creep.carryCapacity) { var sources = creep.room.find(FIND_SOURCES); creep.moveTo(sources[0]); creep.harvest(sources[0]); } else { creep.moveTo(Game.spawns.Spawn1); creep.transferEnergy(Game.spawns.Spawn1) } } for(var name in Game.creeps) { var creep = Game.creeps[name]; if(creep.memory.role == 'harvester') { harvester(creep); } if(creep.memory.role == 'builder') { if(creep.carry.energy == 0) { creep.moveTo(Game.spawns.Spawn1); Game.spawns.Spawn1.transferEnergy(creep); } else { var targets = creep.room.find(FIND_CONSTRUCTION_SITES); if(targets.length) { creep.moveTo(targets[0]); creep.build(targets[0]); } } } } if(creep.memory.role == 'guard') { var targets = creep.room.find(FIND_HOSTILE_CREEPS); if(targets.length) { creep.moveTo(targets[0]); creep.attack(targets[0]); } } ~~~ I get this error [9:12:49 PM]TypeError: Cannot read property 'memory' of undefined at main:3:10 at n:5:28406 at Object.c.runCode:5:34007