Hi guys, today I completed a prototype of an automatic train traffic control system. Those of you who aren't train nerds probably don't know what these things are (hopefully there are some train nerds here), but this system is supposed to account for everything: relay at terminals, switching based on the train's service, and keeping trains from colliding whatsoever. The system even responds to when a train is deleted, since the game has de-spawning trains.
Making the system took me many do-overs, because it became conditionals on conditionals, on conditionals, and so on. Just extremely long scripts, even with variables. Module scripts helped a lot (that's what the system relies on now), but it still has a good amount of separate module scripts, and some of the server scripts are pretty long as well.
I know, long scripts are probably just a necessary evil for this concept. However, one thing I am unsure of is if the setup is worth while. You see, the system relies on a HUGE hierarchy of folders and different Value objects (BoolValues, ObjectValues, etc.). You can see them here:
https://postimg.cc/gallery/2k7gmzaku/
Script-wise, it's maintainable (despite the scripts being really long) because only a handful of scripts account for all the sensors on the tracks (since the sensors are categorized based on their responsibilities). However, the hierarchy that the system relies on has to be set up exactly right, or it won't work.
There are object values for paths, paths that are blocked when a train goes on another path, relay tracks, etc. It is possibly to make any railway system on ROBLOX work following the setup method, but following that setup is super complicated.
This was a lot of reading. If you made it here, thank you. Basically my system works well so far, but I want to make sure it's easy for another person to follow to make his/her own railway network. Should I stick with this system of a huge hierarchy, or do you think there is a better way of failsafe train traffic control?
Of course, the place can be discovered here. I just opened it.
https://www.roblox.com/games/2645547365/Train-Testing-Grounds
Have a great 2019.