Page 1 of 1

Allow more functions to be used in blueprint parameterization

Posted: Sat Nov 30, 2024 4:23 pm
by Iterniam
From what I could find, we can currently use the following functions in the formulas/math expressions field of a value parameter:
  • a * b
  • a / b
  • a + b
  • a - b
  • a ^ b
  • min(a, b)
  • max(a, b)
  • abs(a)
I would like to compute the automated insertion limit as a parameter, the formula for which can be found here viewtopic.php?p=309796#p309796
This requires* ceil() as part of the calculation.
More generally, it would also be nice to have the following formulas available:
  • ceil(a, b)
  • floor(a, b)
  • clamp(a, b, c)
  • mod(a, b) or a % b
  • div(a, b) or a // b (integer division, python style - is the counterpart to mod)
  • and(a, b)
  • or(a, b)
  • xor(a, b)
  • a << b
  • a >> b
  • a == b (these comparisons return 1 or 0)
  • a != b
  • a < b
  • a <= b
  • a > b
  • a >= b
I don't expect all of these to be implemented, but parity with arithmetic combinators would make a lot of sense. Ceil/Floor would also make great additions.

*ceil can be implemented in terms of modulo, so parity with arithmetic combinators would suffice, although it's not elegant

Re: Allow more functions to be used in blueprint parameterization

Posted: Mon Apr 14, 2025 5:13 pm
by wspikes
Adding to this request in hopes of getting "clamp" available. If I recall correctly, "clamp" is already implemented in the scope of a noise expression, but it's not in the base MathExpression.

I was experimenting with a parameterized BP for a bot-based mall assembler, and I hoped to do something like:

Code: Select all

inner_bit => some formula using e.g. p0_i1 and p0_t, for example
clamp(inner_bit, 1, 25)
Note: I split it into two lines and omitted the math for readability purposes. In the actual parameter, they'd be one line.

The goals are that I never want a request=0 bug, and I never want to request more than a hard-coded upper bound at a time (even if that slows it down).

I can and did solve that using min+max, but it's not nearly as clear, especially when inner_bit is expanded:

Code: Select all

max(min(inner_bit, 25), 1)

Re: Allow more functions to be used in blueprint parameterization

Posted: Fri Jun 06, 2025 11:18 pm
by Pluranium_Alloy
+1

Floor/Ceil or even just Mod are severely needed in MathExpression for complicated blueprint parameterisation.

Re: Allow more functions to be used in blueprint parameterization

Posted: Sat Jun 07, 2025 11:37 pm
by danbopes
I'd also love the ability to get the stack size of an item that's used as an ingredient. Currently we can get the "count" of ingredient 1, but no way to get the stack size of that item.