Skip to content

Instantly share code, notes, and snippets.

@ChuckMayo
Created October 20, 2015 21:54
var avoid = [];
if (sourceKeepersInRoom.length)
{
for (var sk = 0; sk < sourceKeepersInRoom.length; sk++)
{
var center = sourceKeepersInRoom[sk].pos;
var top = center.y - 4;
var bottom = center.y + 4;
var left = center.x - 4;
var right = center.x + 4;
// generate room positions for each row and column
for (var rowIndex = top; rowIndex < bottom + 1; rowIndex++)
{
for (var columnIndex = left; columnIndex < right + 1; columnIndex++)
{
var avoidPosition = creep.room.getPositionAt(columnIndex, rowIndex);
if (avoidPosition != null)
avoid.push(avoidPosition);
if (sk == 0)
{
var flagName = rowIndex + ' ' + columnIndex;
}
}
}
}
}
var moveResult = creep.moveTo(target, { avoid: avoid, reusePath: 30 });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment