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

i [feature] Make setmetatable() accessible

4 months ago

Hi,

I would like to write in more OOP manner with support of the IDE and for that I need setmetatable(). Do you see any cons in adding it?

4 months ago
(updated 4 months ago)

x

4 months ago

It's used internally for inputs/outputs, but can probably be wrapped to work in a special way or raise error on those.
More serious issue is that it won't be serialized into savegames, as afaik any code objects can't be saved there.

So I think it'd need some special implementation with caveats and corner-cases, like setmetatable_str() where you actually give it a string of methods' code to save and restore separately between saves somehow.

Don't think I'll implement it, and feel like it might be too complicated of a feature for me to merge without testing, and I haven't played factorio in a while, so probably can't meaningfully do the latter, unfortunately.
But if you're up to it, maybe implement and make a fork of this mod, and I'll just link to it in the Info box as its successor with more features?
(esp. since not sure if I'll ever return to update this mod myself anyway, was thinking to just mark it as deprecated once expansion releases with likely-breaking changes)

4 months ago

Thanks for reply. I added it to env yesterday and it worked but didn't do testing with saves but don't see the difference between this method and table for example.

4 months ago

Test if custom methods stick around after you save/load the game.

It might've changed, but factorio used to not serialize and simply set all code objects to nil after such save/load, so you might have those metatables broken like that after reload. If that was changed, and saves now can include serialized functions too, then I think it indeed removes that issue, and only wrappers around those special input/output vars are needed (to avoid confusing/broken behavior).

New response