how to take the top of stack piece

Hi, I’m a newbie in vassal, and I try to create a prototype.
In the game, you play or discard cards, at the end of the turn, you discard all the cards played, except the last one wich become the first played for the next turn.
the cards may be played frontward or backward (eat, or move)
I have tried some solutions, nothing work
the deck :
I put cards on a deck, and when I press the “end of turn” button, the top of card is placed on a buffer, all the reminder cards return to deck, and the card saved is put on the deck, it work, but…
Wen i put a card on a deck, I have to put the card frontward or backward after the card is placed, i would prefer to switch in my hand, and place it as it will be
the stack :
when i put a card in stack, when i press the button to end turn, all the cards are moved to the buffer
I have created a global property to limit to only one card taken, it work, but…
it save the first card placed in the stack, and I want to save the last one.
does someone has a solution ?
PS : excuse my french, It’s because I am :slight_smile: