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] How to call red/green wire input values

3 years ago

"Note that red/green input tables are always available in the environment"
like the info. said , there are input tables,but i can't find the input Variable,

3 years ago
(updated 3 years ago)

Variables are called just "red" and "green", and can be accessed as red.wood for example in lua environment there.

Click the button with a question mark above code-editing box, it should open a window like this with a more complete list of such special pre-defined variables:

And see also code examples in the same mod description.

That specific "Note that red/green input tables are always available in the environment" in the description of mod options that allow renaming wire colors refers to the fact that you can install e.g. https://mods.factorio.com/mod/ColorblindCircuitNetwork mod, change wire labels in options to "blue" and "yellow" and use these in the code, but any old or copy-pasted code still using "red" and "green" should still work fine too.

2 years ago
(updated 2 years ago)

So I work with moon logic for first time and needed for all wire cables. For now I do

local signalS = red["signal-S"] + green["signal-S"]

Would be nice if this is possible by default something like in["signal-S"] because by default other combinators can read both at same time and they are counted together and the code gets ugly if you want to use by default both wire and write like above.

2 years ago

You should be able to abstract that op away into a function easily though, for example:
local in = function(sig) return red[sig] + green[sig] end

And then use that in all code after that as:
local signalS = in('signal-S')

If you use it mostly for signals, can also auto-prepend signal- prefix there, or can make one-liner to build local table to access those via e.g. sig.S for brevity.

Feel like it might be more confusing than useful in the base mod, given how simple it is, how long and confusing "help" text already is, and given that it clearly duplicates existing functionality without allowing anything actually new.

2 years ago
(updated 2 years ago)

Although come to think of it, maybe some user-controlled "global" piece of code for library definitions would be a better idea, with some new UI button to access it from any combinator. Should be easy to define any custom extensions there, like such "in" function or table.

EDIT: thinking about it just a little more, realized how it'd also easily break/reset every combinator on any issues, and make them non-self-contained, so maybe copy-paste is better anyway, even if it's couple same definitions on all of these. And for really complex stuff, there are hacks via _api or that ota update thingie.

2 years ago

local in = function(sig) return red[sig] + green[sig] end

Oh nice. Thanks for it. This is much better now.

New response