Allow more functions to be used in blueprint parameterization

Post your ideas and suggestions how to improve the game.

Moderator: ickputzdirwech

Iterniam
Manual Inserter
Manual Inserter
Posts: 4
Joined: Wed Nov 13, 2024 8:15 pm
Contact:

Allow more functions to be used in blueprint parameterization

Post 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
wspikes
Manual Inserter
Manual Inserter
Posts: 4
Joined: Fri Jun 10, 2022 4:05 pm

Re: Allow more functions to be used in blueprint parameterization

Post 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)
Pluranium_Alloy
Burner Inserter
Burner Inserter
Posts: 10
Joined: Sun Oct 06, 2019 8:35 pm
Contact:

Re: Allow more functions to be used in blueprint parameterization

Post by Pluranium_Alloy »

+1

Floor/Ceil or even just Mod are severely needed in MathExpression for complicated blueprint parameterisation.
danbopes
Fast Inserter
Fast Inserter
Posts: 101
Joined: Mon Feb 07, 2022 9:29 pm
Contact:

Re: Allow more functions to be used in blueprint parameterization

Post 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.
Post Reply

Return to “Ideas and Suggestions”