How to cycle through different variants by pressing a button?

Hi, I am trying to make it so that when a button is pressed, on each press it cycles to the next variant and will keep looping around if you keep pressing over and over. I am trying to do this with variables but this is my first time using them so I am a bit lost.

Here is the file to follow along:

This is the first thing I tried (since it seems Figma has no else if statements), but when clicking this make it so the map switches straight from Mode 1 to Mode 3. Clicking again after that does nothing even though there is an if MapType = MapType:Mode3 statement.

Am I simply using modes wrong? Variable modes is something I think I understand but I may be wrong, is MapType just a value can can only be assigned one of the mode values? (CloudCoverMap,LightPollutionMap,CombinedMap)?

Even as a test using the else statement just to try and have it be able to toggle back and forth, it doesnt work like I would assume. It works to go from mode 1 to mode 2 but wont do anything after the first tap.

Any help on the best way to do this would be appreciated, thank you very much!

Hey Zach, thanks for reaching out!

Here’s an example of how we would set up 4 variants being cycled through by pressing a single button:

  • Construct a variant set with 4 variants named 1, 2, 3, 4
  • Create a number variable with a default value of 1
  • Create an instance of one of the variants
  • Bind the number variable to that instance
  • For your button, to trigger the cycling, you can use this super basic condition/trigger setup: