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] Combinator Reading Building

2 months ago

How could I make the combinator read data from a building if possible?

I'm working with AAI and I want to use the combinator to read and send out data, how would I code that, I kind of have no experience with Lua coding outside of the coding with the Expression 2 mod for Gmod.

2 months ago
(updated 2 months ago)

If building in question allows circuit network connection with red/green wire, then reading data might be as easy as that.
Lua code will be necessary to do anything with that data of course, as this is a lua code combinator after all :)

If building doesn't support circuit network connection, good option might be to install some other combinator mod that'd do the reading and make such data available.
https://mods.factorio.com/mod/Circuit_Power_Measurement_Combinator for example does that for power, but iirc there were mods to control assemblers and such too.
And then it's back to the first thing - connect that mod-added combinator to lua logic via wire in-game and script whatever you want there.

Last option is using factorio modding API via "_api" value (see last question in FAQ about it), which gives you access to this:
https://lua-api.factorio.com/latest/index-runtime.html
There you can for example find nearest building of specific type to a combinator, and do anything with it that factorio modding API allows to, which is usually pretty much everything, but you'll have to lookup which specific properties/methods to use in the docs, or can also search forums and other mods' code for how they do it.
At that point, you're kinda making your own mod, and if it's something that can be generally useful, can probably throw custom combinator in there and publish as a mod on mods.factorio.com - like that trivial power meter mod linked above.

Question seem to be a bit too broad to give one definitive answer, but hope it helps.

New response