READY FOR USE! Calculations in command line.

  • I was fiddling around with flyout generators and I wanted this. So I 1) tried to write it then 2) realized I'm here to design cool crap and not reinvent the wheel and finally 3) found something and modified it a bit.

    This is pretty basic but I made it recognize command line variables so that's nice I guess.

    This is how far I got tonight, but I wanted to get this out there as I already think it can be useful. Let's make it better!


    1. Use the Set User Var macro to set up some variables

    2. Set $calc_string to something like "$var1+$var2*var3+6*($var1+$var3/$var2+143)"

    3. No spaces! ^^^

    4. Set $calc_store to the name of the user variable you would like the result stored in.

    5. Call Macro "calc" or Lua "calc()"

    6. Also you can just run Lua "calc('$var1+$var2*var3')" if you prefer.


    1. Clamp calculations to real things

    - The included Step ++ and Step -- macros should recognize when the real step value didn't change cause it's at 1 or max step +1 already.

    2. Insert arbitrary MA stuff into calculations like selection width and such.

    3. Run a calculation periodically based on a timer to keep vars up to date.

    4. Pass variable to store result into the calc() function.

    5. ???

    6. Profit!

    Edited once, last by pikipupiba: added todo (February 21, 2022 at 7:28 AM).


    This forum is the best thing ever.

    I was so sure text parsing was the only way...

    Consider this a point of reference to remember the before time when I'm going all big brain mode.

  • Related question!

    How would one go about using a User or Global command-line variable in that structure?

    Also stuff like current MAtricks width, slider value, or attribute value?

  • I think I definitely like my syntax WAYYY more than that! Is there a way to simplify it?

    Maybe some macros or a plugin I could make as an interface? That was my ultimate goal. Make it easier!

    Edited once, last by pikipupiba (February 21, 2022 at 9:45 PM).

  • I think I definitely like my syntax WAYYY more than that! Is there a way to simplify it?

    Google for some tutorials about string manipulation in general (Lua String Library)

    Then study in depth specifically string.gsub(), and its more advanced usage including pattern matching, captures, and functional substitution.

    Chapter 20 of "Programming in Lua" could be a good source for this

  • We did it!

    This is now the final form of easy-to-use command-line math.

    Andreas, you da man!

    If anyone has any cool ideas, let me know and we can make it happen!

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!