I just realized, doing it this way still will cause some issues since grabbing a party monster will move any monsters after it in the party lineup forwards one slot, and the undo overwrites the original slot (so grabbing the first monster when you have only 2 in the party will move the 2nd monster to the 1st slot, then it's overwritten by the undo).
It's probably safer to move the party-amount check to just after line 18 (inside the second "if(menuvalue_x < columns_party){" block), and have the check be something more like this:
var partymons = 0; for(c = 0; c < PARTYSIZE_ACTIVE; c++){ if(amp_read_var(AMP_FIRST_ACTIVE + c,amp_MONID) != NONE){ partymons++; } } if(partymons <= 2){ //Error message code goes here (but without the undo, since we don't always pick up the monster now) } else{ //Regular "pick monster up" code goes here }
So basically, disallow even picking up the monster if you don't have at least 2 after the operation.