C3 File: https://easyupload.io/vtbbr6
What I'm trying to do:
I'm trying to send electricity from generator via cables that can be connected to relays to extend the range and then be connected to machines that consume power.
How I approached it:
I need to recalculate_connections between generator, cables, relays and machines when a cable is created or a cable is destroyed and a generator is turned on/off.
Each cable gets assigned the ID of the generator (gen_id) when created, when connected to a relay or machine it gets assigned the gen_id via cable reference. At creation of the cable on the generator (the first cable for that generator), it gets assigned cable_num of 0, when connected to a relay the relay then has cable_num of Cable.cable_num + 1, and when creating cable from relay cable gets cable_num of Relay.cable_num + 1.
When I turn on the generator, function recalculate_connections runs to calculate which cables and relays are connected to the generator and are receiving power. It goes through the cables and relays checking for overlays and passing active = true. Then for each machine that overlaps a cable that has active = true, machine gets consuming_power = true.
*Relays are the Component object with type instance variable = "relay" in the file.
Problem:
The ID assigning works, as well as passing the power until the cable of the second relay, then the cable remains active = false.
I don't know how to solve this. If you know of a fix or a completely new system for this, I would appreciate it greatly since I'm stuck on this for months now and had tried around 15 different systems, none of which worked.