How do I store the last value pressed out of 3 buttons?

So I have a whole bunch of buttons and pot sliders, I have a group of 3 buttons that work like stop lights, i.e. when one is pressed it lights up and other two are off. I want to store the last value of the button pressed in a variable over each iteration of the "void loop()" part of the code, even if a bunch of other buttons have been pressed, I want to store the last value of these 3 buttons until another one of the 3 is pressed. How can I do this? Thanks for the help!

I'd help if I could, but I'm sorry to say I haven't a clue what that means.

Just to give you the idea.

// buttons between pin and ground
#define ISPRESSED LOW

const byte btn1 = 2;
const byte btn2 = 3;


void setup()
{
  // use pullup resistor to prevent floating inputs
  pinMode(btn1, INPUT_PULLUP);
  pinMode(btn2, INPUT_PULLUP);
}

void loop()
{
  static byte lastButton = 0;

  byte btn1State = digitalRead(btn1);
  byte btn2State = digitalRead(btn2);


  if (btn1State == ISPRESSED)
  {
    lastButton = btn1;
  }
  if (btn2State == ISPRESSED)
  {
    lastButton = btn2;
  }
}

Obviously you're using arrays when using multiple buttons and you can store the index of the button in the array in lastButton instead of the pin number itself.

Only 'problem' is if multiple buttons are pressed at the same time; the last one always wins.

Not tested.