How to make a Circuit puzzle?

Simply put, I've been trying to make a Circuit connetion puzzle like this one:



Yet, I can't find anything remotely close to a guide/tutorial anywhere. Not even here!

Soo, I've tried to recreate it myself in MV with no plugins but no luck so far.

This is what I have:
I have custom sprites for both 'powered' and 'unpowered' states.
I can rotate them with movement route. (Direction fix off, Turn 90°, Direction fix on)
I can switch the sprites with New event page and Self Switch individually.
I've even found Scripts that allow an event to and check and change the Self Switch of another.
To check: $gameSelfSwitches.value([MapID, EventID, 'SelfSwitch']) === Value
To change: $gameSelfSwitches.setValue([MapID, EventID, 'SelfSwitch'], Value);

This are the problems so far:
Whenever a 'powered' event "connects" with an 'unpowered' one, the 'unpowered' one does not update unless it is interacted with and vice versa. "Disconnecting" a 'powered' event does not 'unpowered' the other unless interated.
I don't have a "Completion" event set yet, but I planned to have an event check if the end nodes are powered.

I could really use some help here.
You'll need to show us some actual event pages, otherwise we can only guess where you may or may not have messed up.

But just reading what you've said, you don't need a second event page necessarily. you can change the image directly. I also don't see why you would need to put direction fix on and off. The event isn't moving on it's own. What's the point of doing that?

On a basic level, you'd need to check the facing direction of any interacted with piece, then check if the piece connected to it is facing in a way that has a connection, then check if said piece has power, and if so, turn on the interacted with piece.
Basically whenever you change a single event, you not only need to handle that specific event but check and handle all connected events as well.
You'll need to show us some actual event pages, otherwise we can only guess where you may or may not have messed up.

But just reading what you've said, you don't need a second event page necessarily. you can change the image directly. I also don't see why you would need to put direction fix on and off. The event isn't moving on it's own. What's the point of doing that?

On a basic level, you'd need to check the facing direction of any interacted with piece, then check if the piece connected to it is facing in a way that has a connection, then check if said piece has power, and if so, turn on the interacted with piece.
Ok, you were right about direction fix. It is only necessary if the event is 'Same as character due to the event turning to look at the player, then the mov route.

Now for the rest:
1.png

The 2 cables are the same, except for the EventID.
2.png

3.png

First the Autorun activates the puzzle.
4.png

Then I interact with Cable1.
5.png

Cable1 sees that the SS of the square is ON and turns blue. But Cable2 doesn't, despite facing the right direction and Cable1 having its SS ON. So I go interact with Cable2 to turn it and make it blue.
6.png

Now, I turn Cable1 to cut the power but Cable2 remains ON and im have to interact with it again to turn it OFF.
7.png

That is my Issue.
Basically whenever you change a single event, you not only need to handle that specific event but check and handle all connected events as well.
How, it's the question.
I figure I need something like a parallel event for it but just can´t wrap my head around it.
You're only checking the pipe you're currently turning. Of course the connected ones aren't gonna magically turn on if you don't tell the game to do it.

Basically you need to add more conditional branches. If you turn the middle pipe vertically, you need a branch checking if the top pipe is ALSO vertical, and if so, turn the self switch for the top pipe on as well.

And of course the same is true for the reverse.

The first pipe is easy, since you only need to check if the facing direction is correct because the power source can never be off as soon as the puzzle starts, but the more pipes you add and the more possible connections you got between them, the more checks you'll have to do.

On every pipe turn, you'll need to add a check in that same event for every other pipe that can possibly be connected to determine if they are still powered or should go off.
something like a parallel event for it
yes and no

it might be done by a parallel event, but that has disadvantages and may cause lag.

Doing it without a parallel event like we described is better for performance, but it basically means that every event needs their own variant of the general code.

because you have to follow the logic priority. If an event changes, then you need to give commands to the events connected to that specific event first, before following the chain of reaction from there out.

Original thread: https://forums.rpgmakerweb.com/threads/how-to-make-a-circuit-puzzle.183899/