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] Bitwise operations

2 years ago

Is it possible to use bitwise operations?
I have this line: if ((green.se-vulcanite-block & 2) == 2) then
It is giving me an error: ')' expected near '&'

2 years ago

Yeah, but not as operators.
I think you want "bit32" lua module for those - https://www.lua.org/manual/5.2/manual.html#6.7

Be careful with numbers in lua though, as it's a weird alternating integer/double type.
I think you should be safe as long as you only use 32bits, but going beyond 51 bit (mantissa in IEEE double) will get you some weird unpredictable values :)

2 years ago

Thanks, I was able to get bit32.band to get past the syntax checker. I won't be using more than 32 bits, as I think that's what Factorio uses.

2 years ago

This mod doesn't actually check or tweak lua syntax in any way iirc, just wraps code into "function ... end" and load()'s it with a table of globals.
So everything that there is in factorio lua should be available, but factorio lua does have some things removed and/or changed in there, like file manipulation or making randomness more predictable (for multiplayer to work) - iirc all these tweaks are listed in factorio lua-api docs somewhere or on the wiki.

2 years ago

with a table of globals.

Ah, actually that can be considered a syntax check/tweak all in itself, come to think of it, given that the table looks like this:
https://github.com/mk-fg/games/blob/c408d41/factorio/Moon_Logic/control.lua#L187-L227

New response