Variables

How to create and use variables.

Variables in FancyMenulink

Variables store text values that layouts, actions, placeholders, requirements, listeners, schedulers, and Custom GUIs can reuse.

Creating Variableslink

To create a variable in FancyMenu:

  1. Make sure you're not currently in the Layout Editor.
  2. Click on the menu bar at the top of the screen.
  3. Go to Customization -> Variables -> Manage Variables.
  4. In the "Manage Variables" screen that appears, click the Add Variable button.
  5. Type in a name for your new variable and click OK.

That's it! Your variable is ready to use. You can see it listed in the "Manage Variables" screen.

The Manage Variables window supports a right-click context menu, keyboard navigation, copy/paste, undo/redo, type-to-search, Delete to delete, and Ctrl/Command + S to save.

Setting Variable Valueslink

An empty variable isn't very useful on its own. To make variables work for you, you need to put data into them. In FancyMenu, this is called "setting the variable value."

There are two main ways to set a variable's value:

  1. In the "Manage Variables" screen, find the variable in the list, click it, and then click Set Value. Type in the data you want to store.

  2. While customizing your menu, use the Set Variable Value action on a Button, Slider, or Ticker element.

For example, create a variable named clicks and add the Set Variable Value action to a button:

clicks:{"placeholder":"calc","values":{"expression":"{"placeholder":"getvariable","values":{"name":"clicks"}} + 1"}}

Here's how this works:

  1. The Get Stored Variable placeholder retrieves the current value of the clicks variable.
  2. The Calculator placeholder takes that value and adds 1 to it.
  3. The result is stored back into clicks using the Set Variable Value action.

So each time the button is clicked, the clicks variable will increment by 1, effectively counting the total number of clicks.

Using Variableslink

Now that you have variables holding data, you can use that data in different parts of your menu customization:

Variable Exampleslink

Here are a few examples to inspire your own variable usage:

  1. High Score: Create a highscore variable and a button that sets it to the player's current score if it is higher than the existing value. Display it with the Get Stored Variable placeholder.

  2. Difficulty Selector: Make variables for different game difficulties, like easy, medium, and hard. Use buttons to set the difficulty variable, and show/hide elements based on the selected difficulty.

  3. Tutorial Progress: Add variables to track the player's progress through a tutorial, like tutorial_step. Increment the variable as they complete each step, and use loading requirements to gradually reveal more of the menu.

Persistence, Scope, and Storagelink

Variables are shared across the current Minecraft instance. They are not separated per layout, world, server, or player.

Values are saved immediately in <game-directory>/config/fancymenu/user_variables.db and survive restarts.

  • Reset on Launch empties that variable the next time the game starts.
  • Clear All Variables removes all stored variable values.
  • Names are case-sensitive. Use simple, unique names such as tutorial_step.

The Get Stored Variable placeholder returns 0 when the named variable does not exist or when its stored value is empty. This fallback matters in comparisons and calculator expressions.

The Set Variable Value action uses variable_name:variable_value and splits at the first colon, so the value may contain more colons.

Do not store passwords, tokens, or other secrets in FancyMenu variables. They are readable configuration data.