Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How would you go about scripting a railroad system?

Asked by
Trew86 175
5 years ago

To get this out of the way, I don't mean to advertise, but the place that I've been working on and I'm about to talk about can be found here:

https://www.roblox.com/games/2645547365/Train-Testing-Grounds-W-I-P

I posted about this on this site once before. What I have is a fully automatic train traffic control system that I've tested thoroughly. It accounts for block signaling, switch throwing (based on the route value set by the train's driver), and relaying. However, I am not satisfied with it, yet.

You see, my hierarchy is deep and complex, even with using modules: https://postimg.cc/tsPG8Rsw

And here's a shot of how my modules are set up: https://postimg.cc/NKvz960C

I do know, however, that instead of using all the physical folders and value objects, I could have used modules for that, too. That's the next step I guess, but before I do that, I want to know how other people would go about the daunting task of automatic a railroad that doesn't necessarily go in a loop, but possibly has to use relays.

Explaining the hierarchy:

There are groups and sub-groups of signals grouped into folders based on their differing responsibilities. Some are simple block signals (in the "Simple" folder), others are signals for a single route involving at least 1 switch ("Single-Path"), and other signals, that are indicators for multiple routes, are in "Multi-Path". There are some sub-groups for the 3 main groups, such as Terminal Signals (for relaying trains), and Route Distinguish vs. Non-Route Distinguish (based on whether a Multi-Path signal takes into account the train's route value set by the driver.)

Every time a Path is set, it takes each objectValue for the path's AffectedPaths folder and alerts the signal indicating that path that it is blocked.

Hopefully there are some train nerds here that actually read the whole thing. Has anyone here ever tried something like this or have an idea how they would do this? Thanks!!

1 answer

Log in to vote
0
Answered by
clc02 553 Moderation Voter
5 years ago

Hey there again, I remember you from last time.

Personally I'd make seven separate 'objects', the train, the track, destinations, switches (Where one rail can take two or more paths), sensors, and signals.

Tracks should be one object if they have no destinations, switches, sensors, or signals between them. They should also have a table of sensors, if any, sensing that track, and a number value length

Switches should have two tables, where any track from table A, can reach table B, and vice versa. E.g. 1 to 2 or 1 to 3. Assuming you want automatic switching.

Sensors should have a table of signals that they effect

Signals should have a on or off value on whether they're passable, default to passable.

Trains are the main object, use either preprogrammed paths or traveling salesman algorithm to find the shortest distance, with the length being considered the distance. Have the train travel along the points along the tracks, before embarking on each track check: The point is not it's destination, if so break The point is not a signal, if it is, that it is passable, if not wait The next track has no sensors, if so set the signals of those sensors and continue.

This shouldn't need any loops outside of finding paths, and waiting for the signal to become passable, which you can bypass with events.

0
I have numbered tracks (1, 1B, 2, and M). Should there be a track object for each of those track numbers, or a track object for each block of track separated by a sensor/signal/switch? Trew86 175 — 5y
0
I'm about to head to work, nights, I should be back in 15 hours if snow's not too terrible, I think this might be better in a discord/team create discussion if you're up to it clc02 553 — 5y
Ad

Answer this question