Logic circuits: A flexible node based system, with some unfortunate caveats


Over the course of developing my game I’ve decided to implement a logic system that lets me handle lots of unique inputs and then eventually passes them onto unique outputs, not unlike an electrical circuit.
This system has proven really powerful so far! It’s let me create a few really cool scenarios for my game with the ability to quickly add and change the events that take place!

Heres a few examples of the things I can do with this.

Doors with unique particle effects, camera shakes (and sounds too, despite not being shown.)

EdTech: Additional LogicNodes - YouTube

Environment changing events

Testing things. - YouTube

Tricks and traps!

lil spook - YouTube

Basic inputs and delays

Event based quick-logic system - YouTube

This system works via a series of nodes that operate by taking various inputs the player can perform and working through its node system to its eventual outputs.

Nodes so far;

Entrances:
  • InteractEntrance
  • DestroyedEntrance
Connections:
  • AndNode
  • XorNode
  • DelayNode
Outputs:
  • InteractExit
  • ParticleEffect
  • CamShake
  • Animation
  • SoundEffect

Theres plenty of room and flexibility to add more nodes here, and its actually fairly simple to add more.

The problems I’m currently facing

Using attachments as Nodes and beams as Connections is an incredibly useful method of creating these circuits in a 3d space. But this starts to become a real problem with multiple circuits, as maintenance and readabilty fly out the window.

This is the layout which allows me to have all these connections running.

There are 3 individual circuits in these folders. Not all of the circuits have their exits visible here, and none of the entrance nodes are present.

  • This means that I have no viable way of copy/pasting circuits, because I have no method of properly grouping them.
  • If a problem appears in a circuit, I have to sort through each individual beam object to find the proper connection between 2 nodes.

Reasoning for current layout

  • At run-time, the logic module sorts through all the attachments/beams to create a list of all the Nodes.
  • The module then creates the necessary NodeObject and enters that into an array
  • The Nodes are then linked via their Connections (Beam attachments) as either an Input (Attach0) or an Output (Attach1)
  • All circuits have been fully found and set up, ready for execution, even if they’re not parented to the Links or LogicPoints folders.

Aims with this system

Eventually, I’d really like to release Brutal’s framework. I know I can make a lot with it, but I also know there are people way more talented than me on this platform. The aim is to keep everything code-wise simple/adaptable, so even people with little confidence in scripting can utilize it.

While I’m happy to use the event system as I have it, a public release in this state is unthinkable.

Example circuit, as displayed in the unique doors video


Ew.

Feedback/Discussion

I’m really looking for methods to find ways to properly group these Logic circuits in their own containers, but I’m out of ideas on how to achieve this. Its a powerful system, but its also got some pretty hard limits in its current state.

Thanks for reading this far, really keen to know what your thoughts are on this system, what you’d do with a system like this, and if you’ve got any experience with similair systems!

3 Likes

I’ve just had a response over twitter pointing me towards the CollectionService.
It’s not something I’ve had a lot of experience with before, but it appears to be able to solve a good number of issues I currently have. I’ll have to do some experimenting.

1 Like

Im a little confused by all this, but could you not just create a LogicLinks folder for each circuit as opposed to a global one?

1 Like

It was designed to just look in one place to get everything, and then sort out the links from there. Individual folders could work nicely and is the ultimate aim.

I had a similar problem and my way solution was to use GUIDs (from HttpService) of which the Link would get the Name of, yet also a StringValue inside the Object which had the Value of this GUID.

It makes it much easier to retrieve the Links, though you could also use ObjectValues if you felt like it.

And after a little experimenting with CollectionService;

We work!

I had honestly thought that CollectionService was part of the garbage collection service.

Thats now exactly how this works! Future is looking bright!

1 Like