Page 1 of 1

Framework for connecting two values by reference

Posted: Sun May 07, 2017 5:19 pm
by sparr
I want entity X to always have the same position as entity Y. Doing this in onTick is not very efficient. I would love to have a way to register with the API the fact that one of those values should always mirror the other, and have it handle that behind the scenes.

Re: Framework for connecting two values by reference

Posted: Sun May 07, 2017 6:20 pm
by Rseding91
That's an extremely specific thing to make part of the games code.

Doing it on-tick is exactly what the game would do so doing it on-tick through a mod is almost the same cost.

Re: Framework for connecting two values by reference

Posted: Sun May 07, 2017 7:10 pm
by sparr
I would not want it to be just for entity positions. I would want it to be for any two values.

Two surfaces always having the same time-of-day.

Two inserters always having the same drop position.

Two train engines always having the same color.

Two players always having the same running speed modifier.

etc.

Doing this in C, in a single loop that covers every such request, should be much much faster than every mod needing an onTick handler with separate lua code to do it.