Page 1 of 1

Constant combinator improvment

Posted: Tue Oct 19, 2021 12:00 pm
by Pat4yczek
Hi everyone

This item is usefull, but when you have a lot of signals to set is painfull.
So I think a good idea is to add 3 options
1 is checkbox to set numbers as negative
2 is checkbox with input to multiply
3 is not only here, to set signal as default stack size

Re: Constant combinator improvment

Posted: Wed Oct 20, 2021 5:33 am
by ssilk
Pat4yczek wrote:
Tue Oct 19, 2021 12:00 pm
1 is checkbox to set numbers as negative
You mean to multiply every value with -1 before output?
2 is checkbox with input to multiply
Could be already be done with an arithmetic combinator. :)
3 is not only here, to set signal as default stack size
Don’t understand what you mean. The default stack size is in inserters not constant combinator?! You can set it already to a constant value in the inserter.

Re: Constant combinator improvment

Posted: Wed Oct 20, 2021 10:21 am
by mrvn
ssilk wrote:
Wed Oct 20, 2021 5:33 am
Pat4yczek wrote:
Tue Oct 19, 2021 12:00 pm
1 is checkbox to set numbers as negative
You mean to multiply every value with -1 before output?
2 is checkbox with input to multiply
Could be already be done with an arithmetic combinator. :)
3 is not only here, to set signal as default stack size
Don’t understand what you mean. The default stack size is in inserters not constant combinator?! You can set it already to a constant value in the inserter.
I think he means that when you select a new signal to output by the constant combinator and it is an item that the default value then is the stack size of the item. I think there used to be an option to have default size for selected items be 1 or stack size for something. Was it requester chests? Players request slots?

Looking up the stack size of items and entering it in a combinator is one of the annoying things left every time I blueprint a train station. So +1 for having constant combinators default to stack size for new items, at least as an option.

Re: Constant combinator improvment

Posted: Wed Oct 20, 2021 2:38 pm
by Pat4yczek
with negative numbers should be usefull cuz a lot circuit desings use negative numbers, using aritmetic combinator on constant combitator is not efficient.
2nd statment like upstairs.
with 3rd idea, maybe i could make mod if it's possible to make vallidation for input method

Example:
All aritmetics writed will work 2+2=4, 4*5=20 etc.
about stack size: if you write (-)*20 for iron ore wil give you (-)20*50=10k
for fluids will be amount of storage tank

Re: Constant combinator improvment

Posted: Wed Oct 20, 2021 5:04 pm
by kryojenik
I'm sorry if this is too self promoty...

I don't know if you're using LTN or not, but LTN Combinator Modernized has _some_ of what you're looking for. While it is mostly intended for use with LTN, it can be used as a stand alone constant combinator.

https://mods.factorio.com/mod/LTN_Combinator_Modernized

Re: Constant combinator improvment

Posted: Wed Oct 20, 2021 5:08 pm
by Bilka
I don't understand point 1, if you want a negative number for the signal, just input that negative number as the signal value.

Re: Constant combinator improvment

Posted: Wed Oct 20, 2021 9:16 pm
by mrvn
Pat4yczek wrote:
Wed Oct 20, 2021 2:38 pm
with negative numbers should be usefull cuz a lot circuit desings use negative numbers, using aritmetic combinator on constant combitator is not efficient.
2nd statment like upstairs.
with 3rd idea, maybe i could make mod if it's possible to make vallidation for input method

Example:
All aritmetics writed will work 2+2=4, 4*5=20 etc.
about stack size: if you write (-)*20 for iron ore wil give you (-)20*50=10k
for fluids will be amount of storage tank
I don't get the request for checkboxes. But I do like the suggestion that you could just input an expression and it gets computed.

Not sure what to think about (-)*20. That seems overly complicated to type and ambigious to evaluate. Why not simply have "S" to denote stack size. So you type in "20 * S" or "20S" for short. And then you can just do 1K, 1M, 1G, too. Also ~32 and 2^17.

Would be best if the combinator remembers the original while outputing the resulting value. Shouldn't be too hard to mod if you have the time and incling to learn. Would love to use it or see it added to the LTN combinator mod (which would be a good place to look at as example).

Re: Constant combinator improvment

Posted: Wed Oct 20, 2021 10:45 pm
by Pat4yczek
I don't try lua too much, don't know it have some RE module
It will have than great, long time ago I wrote CNC decoding lib, so write RE expression for one line it's not big deal.

(-) mean optional negative number
* at beginning mean to muliply by stack size
with S it's not problem

Re: Constant combinator improvment

Posted: Thu Oct 21, 2021 1:15 am
by mrvn
Well, - before a number already works. That just falls naturally out of any string to int conversion.

And, yes, LUA has a regular expression module. But that seems like the wrong tool. You want an expression evaluator. Expressions can be arbitrarily complex. So you want to implement a stack machine or simple recursive parser. There are tons and tons of examples on how to evaluate a math expression as it's usually the first example in anything about parsers and grammars.

If you make the GUI side work I would be happy to pitch in with evaluating the strings the user input.

Re: Constant combinator improvment

Posted: Fri Oct 22, 2021 4:14 am
by ssilk
Bilka wrote:
Wed Oct 20, 2021 5:08 pm
I don't understand point 1, if you want a negative number for the signal, just input that negative number as the signal value.
It’s super nervy, if you don’t have a number block on your keyboard. On German keyboard for example the minus is then easy to miss type because of the big distance between minus and numbers.

I really like the idea of having a input for the stack size. I lately searched for example the stack size of some item. I searched about 15 minutes around and there is no way (o.k. I didn’t find one) to find that out in game but by producing that numbers. I don’t understand why this isn’t printed in the item-window.
Or - to find that out by using a constant combinator…

Re: Constant combinator improvment

Posted: Fri Oct 22, 2021 5:13 am
by Silari
ssilk wrote:
Fri Oct 22, 2021 4:14 am
I searched about 15 minutes around and there is no way (o.k. I didn’t find one) to find that out in game but by producing that numbers.
You can get that information (and basically anything else) in-game with the Prototype Browser - Ctrl+Shift+E.

It is weird that the only way to just look it up is with a debug tool though. I've needed that info a few times in my Space Exploration save and keep having to check there.

Re: Constant combinator improvment

Posted: Fri Oct 22, 2021 10:46 am
by mrvn
F4 -> show-debug-info-in-tooltip and then hover over the item. Works inside the constant combinator so you don't first have to produce one to hover over. Works in recipes or crafting menu too.

Re: Constant combinator improvment

Posted: Sat Oct 23, 2021 5:19 am
by ssilk
Besides that, there is also a mod, that does exactly this:

https://mods.factorio.com/mod/stack-combinator
And as part of https://mods.factorio.com/mod/utility-combinators-plus

Re: Constant combinator improvment

Posted: Sat Oct 23, 2021 11:00 pm
by mrvn
ssilk wrote:
Sat Oct 23, 2021 5:19 am
Besides that, there is also a mod, that does exactly this:

https://mods.factorio.com/mod/stack-combinator
And as part of https://mods.factorio.com/mod/utility-combinators-plus
Forget about stack-combinator. That uses a LUA script to compute the values in the on_tick event. You can use 1, 2 or 10 but each one will cut into the UPS.

The suggestion was to just have the input have a stack "unit" so you enter iron plates: 2 stacks and it configures the constant combinator to 200 iron plates. No runtime cost please.