Page 1 of 1

Curcuits: how to compare two unknown signal types?

Posted: Sat Jan 06, 2018 3:45 pm
by wvlad
I need to compare types, not amounts.

E.g. 1st constant combinators sends Oil = 1, 2nd sends Gas = 1, result should be 0
E.g. 1st constant combinators sends Gas = 1, 2nd sends Gas = 1, result should be 1

I need this to be able to set signal type in a one place of blueprint so I don't need to change things multiple times after placement so I have less mistakes.

Re: Curcuits: how to compare two unknown signal types?

Posted: Sat Jan 06, 2018 3:58 pm
by Caine
Can the second one send -1 instead? Then you can add the signals. A nonzero signal means different types, no signal means equal types.

Re: Curcuits: how to compare two unknown signal types?

Posted: Sat Jan 06, 2018 4:01 pm
by DaveMcW
Multiply signal 2 by -1. If it matches the signals will cancel out, otherwise they won't.

Re: Curcuits: how to compare two unknown signal types?

Posted: Sat Jan 06, 2018 4:08 pm
by wvlad
Ok, what if one of them is set manually but another can be in any amounts, e.g. 1 Oil and 5 Oil , 1 Oil and 100 Gas?

Re: Curcuits: how to compare two unknown signal types?

Posted: Sat Jan 06, 2018 4:11 pm
by DaveMcW
You can change any number to 1 with a decider combinator. Each > 1 → Each = 1

Re: Curcuits: how to compare two unknown signal types?

Posted: Sat Jan 06, 2018 4:16 pm
by Caine
Yes, exactly. As comparison you can utilize for example: everything = 0 --> output 1. If they cancel out this will output 1 otherwise it will output 0.

Re: Curcuits: how to compare two unknown signal types?

Posted: Sat Jan 06, 2018 4:49 pm
by Miravlix
Can GAS be = 2?

Otherwise I would use binary.

1 Oil
2 Gas
3 Lube

So you only need one signal, it can contain a really high number of different binary values.

You check if any is active you do:
Signal AND 2 returns 0 if gas isn't active, 1 if active.