mirror of
https://github.com/paradizelost/screeps.git
synced 2024-11-25 02:14:44 -06:00
26 lines
1.0 KiB
JavaScript
26 lines
1.0 KiB
JavaScript
let assignMiners=require('sproc')
|
|
let rolenrMiner = {
|
|
run: function(creep) {
|
|
|
|
if(Game.flags.nrbuild.pos.isEqualTo(creep.pos) && creep.room == Game.flags.nrbuild.room){
|
|
if(creep.memory.destsource===undefined){
|
|
console.log("changing role from nrminer to miner")
|
|
creep.memory.role='miner'
|
|
assignMiners(creep.roomName)
|
|
}
|
|
if(creep.memory.originroom === undefined){
|
|
creep.memory.originroom = creep.room.name
|
|
creep.moveTo(Game.flags.nrbuild)
|
|
creep.memory.role='miner'
|
|
}
|
|
if(Game.getObjectById(creep.memory.destsource.id)==undefined){creep.memory.destsource=undefined}
|
|
let mysource=Game.getObjectById(creep.memory.destsource.id)
|
|
if(creep.harvest(mysource) == ERR_NOT_IN_RANGE) {
|
|
creep.moveTo(mysource);
|
|
}
|
|
} else {
|
|
creep.moveTo(Game.flags.nrbuild)
|
|
}
|
|
}
|
|
};
|
|
module.exports = rolenrMiner; |