Custom Variables: Part 2 — The Unsung Sidekicks


Last time, we cracked open the history and mystery of Flowchart Variables. Today, we meet their quieter, less glamorous partners: VariableDatas.

amanitaComment_01

amanitaComment_02

Quite. They're the reason that you can use a Flowchart Variable as an input for a Command. For example, the Intro and Outro Clips in MA Play Audio.

inspectorScreenshot

See how Intro Clip has a hard null value while Main Clip is set to a var named bgm? Without VariableDatas, you'd always have to "hard-code" the inputs.

amanitaComment_03

amanitaComment_04

amanitaComment_05

amanitaComment_06

Yes, hard-coding as the only option makes things extra time-consuming. With VariableDatas, you'd just assign the song to one variable, have that used in the Play Audios, and then simply change that variable's value when you get a new version of the song.

amanitaComment_07

Yes, the DMV could stand to learn a thing or two from them.

The Old Fungus Way

In Fungus, every VariableData struct had to carry the same boilerplate:

  • A reference to a Variable
  • A raw value
  • Conversion logic
  • A GetDescription() method.

That meant tons of duplication. Every new type meant another wall of copy‑pasted code, and if you wanted to add your own type, you had to dive into the source and repeat the ritual.

amanitaComment_08

Every codebase gets such at some point or several, ours included. Did it work here? Yes. Was it brittle, repetitive and closed off to extension?

amanitaComment_09

Amanita’s Way

In Amanita, we gave these sidekicks a makeover. Instead of each one reinventing the wheel, they all inherit from a generic base class. The base handles references, values, and conversions. Thus, subclasses don't have to bring as many of their own utensils.

amanitaComment_10

Exactly. Much like with Variables, you don’t need to dig into the internals anymore. Define your new type, add a sprinkle of boilerplate, and you’re done. For the curious, here’s a side‑by‑side of the old and new approaches: https://gist.github.com/CG-Tespy/eb8788bf0a6975b07a927d958b30a21c

amanitaComment_11

Harmony restored with the OCP too.

Finally...

VariableDatas may not be flashy, but they’re the glue that makes Variables work so nicely with Commands. In Fungus, they were a bit on the scattered side. In Amanita, they’re more unified, elegant, and future‑proof.

amanitaComment_12

A hale hearty helping of visual rendering!

amanitaComment_13

Leave a comment

Log in with itch.io to leave a comment.