I'm still not sure exactly what you mean, but how about doing the following:
distance(ego,o1,v255);
if (v255 < 5) {
if (!isset(f255)) {
set(f255);
ego_dir = 0;
}
}
else {
reset(f255);
}
You can replace v255 with another variable and f255 with another flag, and you can replace 5 with whatever distance away from the object that you want the ego to stop walking. What this ought to do is when the ego is walking and gets within a certain distance from the object, he'll stop, and then if the player presses an arrow, he should start walking again. If he gets back within the distance again, he'll stop again.
If it's an object that you can pick up, once it gets erased, the distance between it and the ego should always be 255, so the ego shouldn't stop anymore.
There are other ways of doing the same thing.