Syntax for describing 2.0 - style combinators?

Enhance your gameplay with these tools. This category is also the right place for tools useful for modders.
Mod databases, calculators, cheatsheets, multiplayer, scripts, libs and other useful stuff that is not strictly in-game mods.
charredUtensil
Burner Inserter
Burner Inserter
Posts: 11
Joined: Sat Jun 10, 2017 6:38 am
Contact:

Syntax for describing 2.0 - style combinators?

Post by charredUtensil »

Hey folks - A few years decade ago I built a project to help me figure out how circuit networks work and how to build them. In the process, I ended up coming up with a notation to describe circuit networks as a sort of "code". I left that project to rot when changes in Factorio and a few mods started to make circuit development more comprehensible in-game. I'm poking around for some new side project to do outside of work and it occurred to me that after the changes to networks in 2.0 and 2.1, combinators have become somewhat incomprehensible again and it feels like a natural space to return to. The original CNIDE syntax can't begin to describe the new logic. Meanwhile, libraries for manipulating Factorio blueprints have gotten better and I have quite a bit more experience now as well, so I could imagine a project that can "compile" a combinator system to a blueprint - and even decompile it by storing some data like variable names in the comments.

Has anyone else been looking into this stuff in the meantime or is it just me who's insane? Any ideas?
charredUtensil
Burner Inserter
Burner Inserter
Posts: 11
Joined: Sat Jun 10, 2017 6:38 am
Contact:

Re: Syntax for describing 2.0 - style combinators?

Post by charredUtensil »

I've been thinking about this a bit more. The CNIDE syntax is close enough with some modifications:
  • Signals can be referred to with dot notation within most definitions as

    Code: Select all

    WIRE_NAME.signal_name
    .
    • This can create invalid combinations when more than two wires are specified.
    • This also means the input/output wire sections can be omitted if there are no ambiguous signals.
  • For situations where an output signal is taken from and/or sent to only the red or green wire, I have a few ideas:
    • INPUT_WIRE.signal_name as OUTPUT_WIRE.signal_name, where the signal name must be the same in both cases.
    • Flip the conditions unambiguously, since the

      Code: Select all

      1 as
      syntax was already confusing.

      Code: Select all

      1 as signal_name
      becomes

      Code: Select all

      signal_name = 1
      . Then use the intuitive syntax

      Code: Select all

      OUTPUT_WIRE.signal_name = INPUT_WIRE.signal_name
      . Again, the signal name must be the same in both cases. This itself is awkward because the idea of a combinator output doesn't quite map to how any other language uses equals.
    • A special syntax like

      Code: Select all

      signal_name from INPUT_WIRE
      .
    • This might make the "normal" syntax weird.
  • The

    Code: Select all

    1 as signal_name
    syntax can be replaced with some other constant instead of 1 now.
  • Conditions can be specified with

    Code: Select all

    and
    and

    Code: Select all

    or
    .
  • A decider combinator has multiple outputs. Haven't decided if they should be comma-separated yet
  • Add `else` keyword which works as expected.
I still want some way to express the physical location of combinators and how to stub or reference other non-combinator entities. It would also be nice to figure out how to express circuit conditions within those, particularly complex entities like rail signals.
Post Reply

Return to “Tools”