Vexatos / Computronics

A ComputerCraft/OpenComputers addon mod.
125 stars 53 forks source link

Automatic pairing of locomotives to a locomotive relay #289

Closed golyalpha closed 5 years ago

golyalpha commented 5 years ago

It would be great if we could have a locomotive automatically pair with a relay based on it driving above or past it.

I'm currently trying to build a set of stations that only need to know if a train is on a track (already handled) and change/set it's locomotive's destination. Now, from 1.7.10's OpenPeripherals, I'm used to using a combination of ticket printer, adv. item loader, and itemducts along with routing detectors to let the train go, but that is not something I can do right now, with the printer having limited amount of golden tickets (and therefore destinations) to choose from. I thought of using the locomotive relay, but there's the limitation of having a train statically linked to it, and requiring a manual link to a new train every time.

As the get/set destination interface is already existent, there is only one issue preventing me from going further. It would be nice if it could be placed under a holding track, and have it automatically pair with that locomotive. (Possibly even un-pair once the locomotive leaves the track.)

golyalpha commented 5 years ago

Or maybe a different block if that makes the implementation any easier (or makes more sense due to the recipe of the relay - I honestly don't know how expensive it is because I was building it all in my test world with creative), as long as that functionality is there, which I'd think would be pretty cool to have.

Vexatos commented 5 years ago

Using OpenComputers, you can actually place an Adapter adjacent to a routing switch or a routing detector and change the routing tables inside them using code if you then connect the adapter to the network. You can also place an adapter adjacent to or underneath a routing track and change the destination of the ticket placed inside. That would allow changing the destination of any locomotive passing the track to whatever you want. If you use ComputerCraft, place the computer directly adjacent to it for the same effect. Does that do what you want?

The relays are meant for relatively short distances since they only can see 128 blocks anyway, but I think OpenComputers robots are able to attach relay sensors to locomotives if you need that to be automated.

Vexatos commented 5 years ago

Furthermore, the ticket machine itself can also be computer-controlled, and a computer can change the destination of any ticket placed inside, and also tell the ticket machine to print a ticket. You can also place adapters next to various other tracks, like throttle, messenger, or locomotive tracks to change their internal parameters. For finding trains on tracks, the digital signal boxes that Computronics provides are obviously the best choice in most cases. TL;DR If it contains a routing table or golden ticket, Computronics adds support to change the table data or ticket destination using a computer, without ever removing the item from the block. Does that do what you want?

golyalpha commented 5 years ago

That could actually work. I'm gonna try to see if maybe I can use the wired modem block to connect the tracks to a computer over cables, rather than having a computer directly adjacent to the track.

golyalpha commented 5 years ago

I have an update though, the Digital Detector doesn't seem to be doing much with ComputerCraft. I can't ask it for information about a train it's currently detecting, and it's not firing an event I could read through os.pullEvent (I tried both filtering "minecart" and non-filtered pullEvent, and neither get one.)

I tried both attaching it directly (having the computer right next to the block) and over network, same issue.

Vexatos commented 5 years ago

the detector sends an event which you can find using os.pullEvent. Make sure your computer is connected on the side of the detector that has the yellow dot, and it detects passing trains, not stationary trains.

golyalpha commented 5 years ago

Ok, that was the issue. I had the detectors facing the wrong way. I'm fine with the detector sending the event only when the train arrives, that's completely fine.

golyalpha commented 5 years ago

I was able to rework my station system to work with all this. Thanks for the help.