Just off the top of my head, could you set a Global variable so that "push 'X', if (global variable) = 0 then pick up item and set Global variable to 1, else do nothing? The reverse logic would be used for dropping items.
Would something like that work?