How would one simulate a math operation with source entities?

adamspurgin

L1: Registered
Mar 22, 2010
42
1
let's say i have a math operation, it could be any math operation, like:
x = y
y = z + 5
z = (5 * t) - (3 + x / 2)

using math_counter entities and logic_relay entities, is there a way to have that operation performed on the target variable? i need to ensure the specified order of operations stays intact, so the "inside" values need to be evaluated first

for the last example, the math_counters would be arranged like this:
zFUhk.png

each arrow represents a SetValue/Add/Minus/Divide/Multiply input and the gen_X math_counters are used for the purpose of holding values, but i'm not sure how i would ensure they evaluate in the correct order. any ideas for a generic solution to this problem?
 

adamspurgin

L1: Registered
Mar 22, 2010
42
1
the only thing i could think of at the moment is to break it down into postfix notation and have a HUGE list of outputs on one entity, but i'm hoping for a more elegant solution.
 

A Boojum Snark

Toraipoddodezain Mazahabado
aa
Nov 2, 2007
4,775
7,669
Are you asking this in general, or do you actually need that equation set up efficiently? The best setup largely depends on where/how the input values are coming from, and what values need to be retained. There is no single answer.
 

adamspurgin

L1: Registered
Mar 22, 2010
42
1
Are you asking this in general, or do you actually need that equation set up efficiently?
in general.

The best setup largely depends on where/how the input values are coming from, and what values need to be retained.
the input values are the current values of the math_counter entities on the map. the only entities that should be changed is the target entity and the generated entities. the generated entities serve as a way to preserve parenthases groups.

There is no single answer.
yeah, i realize this. if all else fails i could fall back on a more primitive way of doing this, but i'd prefer to keep the functionality i was aiming for in the first place.
 

A Boojum Snark

Toraipoddodezain Mazahabado
aa
Nov 2, 2007
4,775
7,669
By input values, I meant the value of the variables, X and T. Those are the "equation inputs" that would start the entire calculation chain. What kind of entity is sending them (i.e. when and how fast they come in, which one might come before another), plus whether or not you want to get the value on demand or desire a continual flow of Z whenever it changes, all needs to be known to do it efficiently.

I've done lots of mathematical entity chains, and each one is pretty different according to the situation.
 

adamspurgin

L1: Registered
Mar 22, 2010
42
1
i'm having a hard time putting my thoughts to words, but i hope you understand. i recently got the setup for a constantly updating operation, but my current issue has different problems.

(also, everywhere there's a '<=' it should be '<-', it's what i'm defining as the relational operator for the moment)

xrUjL.png
 
Last edited:

Mr. Happy

L6: Sharp Member
Jul 16, 2008
320
158
So then you would use the door's OnOpen output to trigger the function. You would need an output on the Z math_counter OnGetValue to pass the value to x with Add after a SetValueNoFire 9. Of course the problem is that it would pass the output to x everytime you getvalue so if you need getvalue for other instances you want an intermediary entity to gold the value and the Add I/O so that the link can be broken. You could use a second math_counter that grabs the Z value everytime it changes and then use GetValue on that.

So,

OutValue(z) -> SetValueNoTest(zclone)
OnOpen -> SetValueNoTest(x) 9
OnOpen ->GetValue(zclone) WAIT 0.01
OnGetvalue(zclone) -> Add(x)

This should make all the values pass properly and still allow you to control when they pass. The zclone math_counter always mimics z and is used to adjust x after x has been set to 9.
 

adamspurgin

L1: Registered
Mar 22, 2010
42
1
oh! i get it!

i can use the same framework from my relation setup, but have it target a clone of the target. when the condition is met, the clone sends a SetValue to the target and voila, it works!

i'm not sure if that's what you were getting at, but what you said certainly got me there. thanks, i was over thinking the problem.