Moon Logic deprecated

by mk-fg

Adds Lua-programmable circuit network combinator. Based on Sandboxed LuaCombinator and LuaCombinator2 mods. Probably won't work in multiplayer games.

Content
2 years ago
1.0 - 1.1
4.97K
Circuit network

g [lua-qiz] Bug or not? Outdated ouput signals not clearing by default.

3 years ago
(updated 3 years ago)

I'm not sure it's bug or not.

Write this code:

if red['signal-N'] then
    out['signal-' .. red['signal-N']] = 1
end

Send signal N with value 3 to red input.
In output we have signal 3.

Next. Change value of input signal to 5.
In output we should have signal 5.
But we have both 3 and 5!

For fix this behavior we just can add out = {} before our code. Ok.
However I can not imagine the situation when such behavior would be useful.

3 years ago
(updated 3 years ago)

I'm not sure it's bug or not.

If it's documented to work like that, it cannot be a bug by the definition of the word "bug" :)

3 years ago
(updated 3 years ago)

For fix this behavior we just can add out = {} before our code. Ok.
However I can not imagine the situation when such behavior would be useful.

It's mostly historical thing actually - that's how "out" worked in previous LuaCombinator mods, so I just copied that familiar behavior from there.

Can be useful if you process and output many signals, so that you don't have to explicitly set them all every time.
And I tend to use it as a state too, as you can see in examples in the mod description - e.g. out.stone = out.stone + <something>.

Such things can't be easily changed in this mod at this point, since it can obviously break all existing uses of it, unless enabled via some option, and as you mentioned workaround is pretty trivial, if you need the thing cleared before code runs.

3 years ago

Ok, I understand. I just did not notice it in documentation. Sorry about this.

3 years ago

No worries! :)

New response