! Swap.h
! created june 04 by she's long gone
! from a suggestion by andrew plotkin
!
! please send all feedback to she's long gone
! ( [email protected] )
!
! this file is public domain.
! it will 'swap' two objects,
! moving each to the other's parent.
! note that unless the 'flag' variable is
! non-zero, a swapped object will
! be removed if the other has no parent.
!
! #Include after "Parser".

[ Swap a b flag pa pb;
 pa = parent(a);
 pb = parent(b);
 if (pa) { move b to pa;
               if (b == player) location = pa;
           }
       else if (~~flag) remove b;
 if (pb) { move a to pb;
               if (a == player) location = pb;
           }
       else if (~~flag) remove a;
 #ifdef DEBUG;
 print " (", (The) a, " and ", (the) b, " have been swapped.) ";
 #endif;
];