Try this then, was a small mistake with directions
Code:
local dirs = {2, 3, 0, 1} -- south, west, north, east
local minDist = 1 -- distance from myself to turn, might want to add a table with creatures and separate distances if you want to use it with rp/ms/ed
Module.New("", function(mod)
local target = getSelfTargetID()
if (target > 0 and Creature.DistanceFromSelf(target) <= minDist) then
local dir = Creature.LookDirection(target)
local time = os.time()
while (Creature.isAlive(target) and Self.LookDirection() ~= dirs[dir+1] and os.difftime(os.time(), time) <= 2) do
doSelfTurn(dirs[dir+1])
wait(300)
end
end
end)