Nice work! I found one bug: both portals only transfer the beam in one direction (cyan to blue and yellow to red respectively). I think this is because of their order in the array and the fact that you skip over each player's second portal while scanning.
I changed the implementation slightly:
tech details
||The value type of the "sendtor_active" attribute has been changed from yes/no to a number. -1 means that the portal is closed, any number >= 0 means the portal is open, and that number is its linkage ID. The different portal detectors each get different outputs added to them, to set this up correctly.
When a beam trace starts, the script first builds an array containing all active portals and their IDs, in no particular order. When searching for a portal's partner, it just searches through that array until it finds a portal with a matching ID, that is not the "incoming" portal. (If no match is found, it means that the initially detected portal currently has no active partner, so we should disregard it.)
The nice thing about this is that it's not specific to coop. You could just as easily make a SP map with two sets of portals (like Mevious and Omnicoder have done), or have as many pairs open at once as the engine will allow without tripping over itself, if you so desire. As long as you add a detector for each ID you use, it will just work.||
By the way, I found out that "OnMapSpawn" does get triggered in coop, at least in splitscreen mode. So I'm holding off on duplicating all of the logic_auto outputs for now.
As soon as I'm done with the beam effect tweaks, I'll upload a new version of the source code.
Again, thanks for your help with this!