#Custom Graphics Button

1 messages · Page 1 of 1 (latest)

hollow furnaceBOT
#

Create a button that toggles a variable and use that variable to update the label/graphics.

  1. Make a new variable (e.g. gfx_mode) via Customization → Variables → Manage Variables and set it to FANCY.
  2. Add your custom button and right-click it → Edit Action Script. Build a script with an IF block that checks Is Variable Value [FM Variable] for FANCY (set mode to opposite, so the block runs when it’s not FANCY).
  3. Inside the IF, add Set Variable to gfx_mode:FAST; append an ELSE block with another Set Variable to gfx_mode:FANCY. This alternates the variable each press.
  4. Use {"placeholder":"getvariable","values":{"name":"gfx_mode"}} wherever you need the text to change (button label, texture decision via loading requirements, etc.).
  5. Combine the variable with loading requirements or placeholders to switch textures—e.g. add two Image elements (FANCY/FAST visuals) and require gfx_mode to match.

See the “Toggle Parts of Layouts” guide for the full variable toggle workflow: Toggle Parts of Layouts.

mint timber
#

Can you walk me through building the action script?

hollow furnaceBOT
# mint timber Can you walk me through building the action script?

Sure! Here’s how to build the action script for the button:

  1. Create the variable (if you haven’t yet) via Customization → Variables → Manage Variables. Name it e.g. gfx_mode and set its initial value to FANCY.

  2. Right-click your button → Edit Action Script.

    • Click Add IF Statement.
    • Add the requirement Is Variable Value (FM Variable).
    • Set it to check gfx_mode:FANCY and enable the OPPOSITE mode (so the IF runs when the value is not FANCY).
    • Inside the IF block add a Set Variable action with value gfx_mode:FAST.
  3. Click “Append ELSE Statement” under the IF. In the ELSE block add another Set Variable action with value gfx_mode:FANCY.

Now each click will flip the variable between FANCY and FAST.

To show the current text/graphics, use {"placeholder":"getvariable","values":{"name":"gfx_mode"}} as the button label or as part of loading requirements for alternate textures. The Toggle guide has the same pattern if you want screenshots: Toggle Parts of Layouts.

mint timber
#

It didn't work.

hollow furnaceBOT
# mint timber It didn't work.

Aw, bummer 😕 Let’s get it working!
Could you tell me what exactly happened?

  • Does the variable update when you click the button (you can check via Customization → Variables → Manage Variables)?
  • Is the button label/graphics still stuck on one value, or does nothing happen at all?
  • Maybe there’s a typo in the variable name (e.g. gfx_mode vs gfxmode)?

If you can share the exact action script you built and how you’re using the getvariable placeholder for the label/graphics, I can point out what needs tweaking.

mint timber
#

It's not changing the graphics mode.

hollow furnaceBOT
# mint timber It's not changing the graphics mode.

Let’s double-check the script so it actually flips the gfx_mode variable:

  1. Variable: Make sure gfx_mode exists and starts as FANCY (Customization → Variables → Manage Variables).

  2. Action script structure:

    • Right-click button → Edit Action Script → Add an IF statement.
      • Add requirement Is Variable Value (FM Variable)
      • Configure it to check gfx_mode:FANCY (no “opposite” needed).
    • Inside that IF block, add Set Variable with value gfx_mode:FAST.
    • Append an ELSE block and add Set Variable with value gfx_mode:FANCY.

Clicking the button now runs the IF, so if the variable is FANCY it becomes FAST, otherwise it goes back to FANCY.

  1. Graphics:
    • For the button label use {"placeholder":"getvariable","values":{"name":"gfx_mode"}}.
    • For textures, make two image elements (one for FANCY, one for FAST) and give each an Is Variable Value requirement matching the mode (or use loading requirements on the button itself to switch textures).

If you still see no change, check the variable’s actual value in the manager and confirm the action script shows that IF/ELSE with the actions inside each block. The Toggle guide has the same pattern step-by-step if you want a visual reference: Toggle Parts of Layouts.

mint timber
#

There's a value called "graphicsMode" why aren't you using that?